I have used local storage for file storing. I have created table of file, in which title, path, card_id rows stored.
$request->file('file')->storeAs('public/upload',$files->getClientOriginalName());
i.e:passport.png stored at /home/dhruv/MyProject/storage/app/public/upload/passport.png
Above works fine but I'm getting error while downloading file. in controller...
public function getDownload($file_id)
{
$file = File::find($file_id);
//print_r($file);
return response()->download($file->path);
/* return response()->download(
$file->path,
$file->name,
[],
'inline'//attachment
);*/
}
I tried many downloading methods but any didn't work fine. I am getting this error.
Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException: The file "/home/dhruv/MyProject/storage/public/upload/passport.png" does not exist in file /home/dhruv/MyProject/vendor/symfony/http-foundation/File/File.php on line 37
I dont know why it is searching at /home/dhruv/MyProject/vendor/symfony/http-foundation/File/File.php since i have inserted correct path.
So suggest any method for downloading ..
/home/dhruv/MyProject/storage/public/upload/passport.png
file – Sohel0415