You are saying that you can view the image in Chrome, but you cannot download? Seems to me something wrong with Chrome. You tried any other browser or try to CURL it?
Response download not working on Server
Hi guys,
So I'm working on a project where users can upload big images and where the admins can view those images and download them as well.
The problem is that this works fine locally, but on my server (managed with Forge) it's not working. The viewing part is working fine, but the download part isn't.
It probably related to the download problem, but when I view the image in the browser (which is working fine) and when I try to download the file with my right mouse button I get a failed exception from Chrome as well that the file is invalid to download
It sounds to me like it is a permission issue or something else, but I can't find any solution to the problem so far.
The viewing part is working fine using the following code.
public function show($filename);
{
$path = storage_path($filename);
return response()->file($path);
}
Now the download part is done like so
public function download($filename)
{
$path = storage_path($filename);
$headers = array('Content-Type' => File::mimeType($path));
return response()->download($path, $filename, $headers);
}
If you need more information let me know ;) Any feedback or help would be appreciated!
It must be chrome I guess. If I do the same action in Safari it works fine! It just downloads the file and gives zero errors.
Now for the extra info. My curl command does show a 404 when downloading the file. However the files is downloaded correctly
< HTTP/1.1 404 Not Found
< Server: nginx/1.9.9
< Content-Type: image/jpeg
< Content-Length: 1286256
< Connection: keep-alive
< Cache-Control: public
< Last-Modified: Wed, 03 Aug 2016 10:03:14 GMT
< Content-Disposition: attachment; filename="urenbriefje.jpg"
< Accept-Ranges: bytes
< Date: Mon, 08 Aug 2016 08:25:17 GMT
Please or to participate in this conversation.