Try this
Storage::download(Storage::url($image->image), $image->title);
how to access the file to be downloaded, whether it's in the folder
public / storage/uploads/
or
storage/ app/ public/ uploads
in my blade
<a href="{{route('download', $showUpload->id)}}" class="btn btn-primary">Download File</a>
in web
route::get('/download/{upload}', 'UploadController@download')->name('download');
in controller
public function download($id)
{
$image = Upload::find($id);
return Storage::download($image->image, $image->title);
}
and i get this
File not found at path: uploads/DOmAghSx3UydRznQQUNSgKfp3jXD503VxccalnJo.png
It depends on how you set up your storage driver. By default, the driver is set to local which means all files are stored inside /storage/app if you upload a file using the storage methods in Laravel.
Storage::download('file.jpg');
Note that the above code assumes that the file is stored in /storage/app/public/file.jpg
In your case, $image->image need to return uploads/file.jpg. Also, make sure that this file actually exists on that location.
The /public/storage/uploads/ directory is actually a symlink to /storage/app/public/uploads. The should contain the exact same files because of the symlink.
Documentation: https://laravel.com/docs/8.x/filesystem
When using the local driver, all files that should be publicly accessible should be placed in the storage/app/public directory. Furthermore, you should create a symbolic link at public/storage which points to the storage/app/public directory.
Please or to participate in this conversation.