I have an script that receives an encrypted url and from that generates a download, the most critic par of the script is this:
$MimeType = new MimeType();
$mimetype = $MimeType->getType($filename);
$basename = basename($filename);
header("Content-type: $mimetype");
header("Content-Disposition: attachment; filename=\"$basename\"");
header('Content-Length: '. filesize($filename));
if ( @readfile($filename)===false ) {
header("HTTP/1.0 500 Internal Server Error");
loadErrorPage('500');
}
Downloads works as charm in any Browser except IE, I have seen problems related to 'no-cache' headers but I don't send anything like that, they talk about utf-8 characters, but there is not any utf-8 characters
(and the $filename has not any utf-8 characteres neither).
Firefox includes a download protection feature to protect you from malicious or potentially harmful file downloads. If Firefox has blocked an unsafe download, you will see a warning message about the file in the Downloads panel, along with options for handling the pending download.
This error means that your computer's security settings blocked the file. Learn more about blocked downloads. On Windows: Windows Attachment Manager could have removed the file you tried to download. To see what files you can download or why your file was blocked, check your Windows internet security settings.
Issues with Internet connectivity and the stability of the connection can cause downloads to fail, especially if the Internet connection is interrupted. When an Internet connection is unstable, it may disconnect and reconnect intermittently.
I solved it by sending the headers
header('Pragma: public');
header('Cache-Control: max-age=0');
I didn't knew that session_start() send headers by it's own.
I found the answer in the comments section of: Error: Internet Explorer Cannot Download FileName from WebServer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With