how to use Storage::download()
this is my method
public function download($id)
{
$file = File::find($id);
$link = json_decode($file->link);
return Storage::download('storage/' . $link[0]->download_link);
}
but it wont download the file, I get a file not found exeption
League \ Flysystem \ FileNotFoundException
File not found at path: storage/files/May2019/caAsV09m4I5FZdOmALIZ.png
the path i correct though, not sure why its not working
when I do it as a link on the front end it works, but doing it from a method in the backend does not work for some reason
am I using the function correctly?
It may caching issue, clear the laravel cache by following command
php artisan cache:clear
php artisan route:cache
php artisan config:cache
php artisan view:clear
or if still this not work then try
return Storage::download("your path after storage/App", $link[0]->download_link);
i hope this will work for you.
@JAY_CHAUHAN - can you help me bro my question
how to pass id into middleware in laravel
@JAY_CHAUHAN - clearing the cache didnt work, as for the other one i did this
return Storage::download('storage', $link[0]->download_link);
but i get
The filename and the fallback cannot contain the "/" and "\" characters.
@michalis please send me what contains a $link[0]->download_link
This is some id or anything text
also send where is your file in storage folder (extact location like storage->public->abc.txt etc) .
@JAY_CHAUHAN -
return Storage::download($link);
in this code, link is
C:/Users/com2go/Desktop/code/social_manager/public/storage/files/May2019/4ZLCxnK7Py2J1NpQTlS9.cs
and the path of the file on the hard drive is
C:/Users/com2go/Desktop/code/social_manager/public/storage/files/May2019/4ZLCxnK7Py2J1NpQTlS9.css
@michalis
try this one
return Storage::disk('public')->download($file->path);
i ended up using response()->download(file)
Please or to participate in this conversation.