When i upload my files to the server, it works fine and displays in my public folder as img/php786W
. I am currently trying to retrieve my folder but i get file not found on server.
In my controller, $filename
is returning the original name of the file on the server. So it does not match to be found although it is the same file. How can i get this done? I tried to use hashName() but that won't work
Controller
$file_path = public_path() . '/img/'. $filename;
if (file_exists($file_path->hashName()))
{
return Response::download($file_path, $filename, [
'Content-Length: '. filesize($file_path)
]);
}
else
{
// Error
}
Use
return response()->download($pathToFile);
If this does not work you have either permissions problem, or the file simply does not exist
See docs