Storage facade provides filesystem abstraction.
Disks
local� storage/apppublic� storage/app/publics3� Amazon S3
Storage facade provides filesystem abstraction.
local � storage/apppublic � storage/app/publics3 � Amazon S3Storage::put("file.txt", "content"); $content = Storage::get("file.txt"); $exists = Storage::exists("file.txt"); $url = Storage::url("file.txt"); Storage::delete("file.txt"); $files = Storage::files("directory");
<?php use Illuminate\Support\Facades\Storage; // Local disk Storage::put("file.txt", "Hello!"); // Public disk (symlink: php artisan storage:link) Storage::disk("public")->put("avatars/1.png", $contents); // Read $content = Storage::get("file.txt"); // Exists / delete $exists = Storage::exists("file.txt"); Storage::delete("file.txt"); // URLs $url = Storage::disk("public")->url("avatars/1.png"); $size = Storage::size("file.txt"); // Cloud (S3 example) Storage::disk("s3")->put("uploads/notes.txt", "Data"); // Directory scanning $files = Storage::files("avatars"); $all = Storage::allFiles();
Write to a file and read it back.
Storage::put("data.txt", "Hello");
$content = Storage::get("data.txt");
Which disk is publicly accessible?
The public disk serves files via public URLs.
Abstracts the filesystem, allowing switching between local, S3, or other drivers without changing code.