Laravel 5.4 Storage : downloading files. File does not exist, but clearly it does

Try this:

return response()->download(storage_path("app/public/{$filename}"));

Replace:

$file = Storage::disk('public')->get($filename);
return response()->download($file);

With:

return response()->download(storage_path('app/public/' . $filename));

response()->download() takes a path to a file, not a file content. More information here: https://laravel.com/docs/5.4/responses#file-downloads


If any one still could not find their file even though the file clearly exists then try

return response()->file(storage_path('/app/' . $filename, $headers));

It could be due to a missing directory separator or it isn't stored inside the public folder.

Tags:

Laravel