What is file storage?
Laravel provides a powerful filesystem abstraction built on top of Flysystem. A single, consistent API works across local storage, SFTP, Amazon S3, and compatible services — switching drivers requires no changes to your application code.Changing the driver doesn’t change your code. Use the local driver in development and S3 in production without touching your application logic.
Configuration
Filesystem configuration lives inconfig/filesystems.php. A disk is a named combination of a driver and a storage location.
The local driver
Thelocal driver operates relative to the root directory defined in your filesystems configuration. The default root is storage/app/private:
Change the default disk
Set theFILESYSTEM_DISK environment variable to switch the default disk:
The public disk and symbolic links
Thepublic disk is for files that should be accessible from the web. By default it uses storage/app/public. To make those files accessible, create a symbolic link from public/storage to storage/app/public:
1
Create the symbolic link
2
Generate a URL to the file
After the link is created, use the
asset helper to build a URL:Basic operations
Reading files
Writing files
When
put fails it returns false by default. Set 'throw' => true on the disk configuration to throw an exception instead.Deleting files
Download responses
Generating URLs
Regular URLs
local driver returns a relative URL such as /storage/file.jpg. The s3 driver returns the full remote URL.
Temporary URLs
Generate a time-limited URL for private files. Available for thelocal and s3 drivers:
Uploading files
Automatic file name (store)
Explicit file name (storeAs)
Upload to a specific disk
Using the Storage facade
File visibility
Flysystem controls public and private access through visibility:Working with multiple disks
Amazon S3 configuration
Install the package
Environment variables
S3-compatible services such as DigitalOcean Spaces, Cloudflare R2, and Vultr Object Storage work with the
s3 driver. Add an endpoint option pointing to the service’s URL:File metadata
Directory operations
Testing
UseStorage::fake() to test file operations without touching a real disk:
UploadedFile::fake()->image() requires PHP’s GD extension.