Storing Files in the Public and Storage Folders
Laravel gives uploaded and generated files a couple of natural homes, and choosing correctly between them affects both security and how easily files can be served to visitors.
The storage Folder
By default, files are stored inside storage/app, which isn't directly accessible from the web. This is the right choice for anything that shouldn't be publicly reachable by guessing a URL, like private documents or user-specific files.
The public Folder
Files that do need to be accessible directly through a URL, like profile pictures or product images, are typically stored using the "public" disk, which points to storage/app/public. A symbolic link connects this folder to the actual public/storage path so the web server can serve it.
| Location | Publicly Accessible? | Typical Use |
|---|---|---|
| storage/app | No, by default | Private documents, internal files |
| storage/app/public | Yes, via symbolic link | Profile photos, product images |
| public/storage | Yes, directly | The publicly served link to the folder above |
Setting Up the Public Link
- The
php artisan storage:linkcommand creates the necessary symbolic link - Without this link, files stored on the public disk won't actually be reachable
- Cloud storage disks, like S3, don't require this local linking step
Manually managing paths across these different locations gets repetitive fast — which is exactly the problem Laravel's Storage facade is designed to solve.
Ready to master Laravel Training Course?
Join Uncodemy's hands-on Laravel program and build real, production-ready applications.
