Laravel - File Storage - The Public Disk
The public
disk included in your application's filesystems
configuration file is intended for files that are going to be publicly accessible. By default, the public
disk uses the local
driver and stores its files in storage/app/public
.
To make these files accessible from the web, you should create a symbolic link from public/storage
to storage/app/public
. Utilizing this folder convention will keep your publicly accessible files in one directory that can be easily shared across deployments when using zero down-time deployment systems like Envoyer.
To create the symbolic link, you may use the storage:link
Artisan command:
php artisan storage:link
Once a file has been stored and the symbolic link has been created, you can create a URL to the files using the asset
helper:
echo asset('storage/file.txt');
You may configure additional symbolic links in your filesystems
configuration file. Each of the configured links will be created when you run the storage:link
command:
'links' => [
public_path('storage') => storage_path('app/public'),
public_path('images') => storage_path('app/images'),
],