Laravel Download FIle from storage Hi,
return Storage::download($file['path'], $file['name']);
I am using this way to download some files I have in the storage but it's throwing
Unable to retrieve the file_size for file at location: nameofthefile.pdf
What does this give you?
dd(Storage::exists($file['path']));
@Sinnbeck false...
My File is Stored in storage/app/public/files
@Kris01 you need to provide it the proper path (or disk)
Is this better? If not you need to tell me what $file['path']is
dd(Storage::disk('public')->exists($file['path']));
@Sinnbeck File['path'] is actually the file name, which is stored in storage/app/public/files
@Kris01 ok so how about
dd(Storage::disk('public')->exists('files/'. $file['path']));
@Kris01 like this
return Storage::disk('public')->download('files/'. $file['path'], $file['name']);
@Sinnbeck It works, but I don't know why when I put a custom name, it doesn't download it as pdf, but as something else, just file
@Kris01 just file? So the file is named "file.pdf"? Or
@Sinnbeck My bad, I was not adding .pdf, yes the file name was just 'filename'.
got it thank you
Thank goodness this search comes up high in Google.
What throws one off is the file_size bit but it's actually just a file not found problem.
In my case I'm was using Barryvdh/DomPDF facade and naively thought this line would happily find it in the right place when I download:
$pdf->save(storage_path() . "/invoice_$invoice->id.pdf");
In fact I had to go over the paths with a magnifying glass before I could figure it out. This line from @sinnbeck was the big clue:
dd(Storage::exists($file['path']));
Please sign in or create an account to participate in this conversation.