What's the difference between storing files (images) in public/images
folder and storing them in storage/app/public
?
Laravel's filesystem configuration file is located at config/filesystems.php . Within this file, you may configure all of your filesystem "disks". Each disk represents a particular storage driver and storage location.
The files and folders in laravels public folder are meant to be web accessible. For security, all other files and folders in the laravel framework should not be web accessible.
I just got useStoragePath() method inside of Laravel Container. To change storage folder location, just add this code inside bootstrap/app. php and after $app variable initialized. Please sign in or create an account to participate in this conversation.
Public folder means files will be publicly accessible. For example an image stored in public/images/my-image.jpeg
can be viewed by anyone by going to
mysite.com/images/my-image.jpeg
However, files stored in storage
directory are only available to your app.
Laravel has a php artisan storage:link
command that adds a symlink to public
from storage/app/public
The reason for this is that your storage
may not be your local filesystem, but rather an Amazon S3 bucket or a Rackspace CDN (or anything else)
You will need to setup your filesystem configurations by following the docs https://laravel.com/docs/5.6/filesystem
Once this is done you can get/store files to/from the storage place rather than have everything on your server.
There are 2 helper methods for public
and storage
to show files:
storage: storage_path('my-file.jpg')
public: asset('my-file.jpg')
If you want some control over who can access what files, put the file into storage.
If everyone can access the file (including non logged in users), put into public
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With