It looks like it's not passing the correct path to the download call. Can you dd() the $filename and post that here? It might miss a slash somewhere or the path might be incorrect.
Feb 14, 2018
7
Level 1
call to undefined Symfony\Component\HttpFoundation\BinaryFileResponse::header()
I got this specific error Call to undefined method Symfony\Component\HttpFoundation\BinaryFileResponse::header()
when I followed this article https://laravel.io/forum/04-23-2015-securing-filesimages
I was trying to access images in laravel storage and using their path as an img src.
Following the guide, I wrote this in one controller
public function getFile($filename)
{
return response()->download(storage_path($filename), null, [], null);
}
routes
Route::get('file/{filename}', 'CustomersController@getFile')->where('filename', '^(.+)\/([^\/]+)$');
it doesnt return any image so I tried debugging by accessing http://localhost/hulugan.DEV/public/file/img/placeholders-thumbnail/h.jpg
then it leads to the call to undefined method error
What should I do to fix the error
Please or to participate in this conversation.