Laravel 5.4 storage file not found
This problem happen to me after moving project to different folder. If you already have storage link generated, try to delete public/storage folder and run again:
php artisan storage:link
By default Laravel puts files in the storage/app/public
directory, which is not accessible from the outside web. So you have to create a symbolic link between that directory and your public one:
storage/app/public -> public/storage
You can do that by executing the php artisan storage:link
command (docs).
In laravel ^5.8:
- Make sure you run the command
php artisan storage:link
to linkstorage/app/public
withpublic/storage
.
now:
// this return some like 'public/documents/file.ext'
$path = $request->paper_file->store('public/documents');
// this return some like 'storage/documents/file.ext'
$publicPath = \Storage::url( $path) );
// this return some like '< APP_URL env variable >/storage/documents/file.ext'
$url = asset( $publicPath );