When using php header to download files, it always prompts that it cannot be downloaded under IE6, but Google Chrome is normal, so it should be a problem with IE. There is a bug in IE, and there is a description on the Microsoft official website. Error message: "Internet Explorer cannot download a file" (Internet Explorer cannot download a file), there is a good way to solve it,
Look at the code:
A function is compiled below
The code is as follows
代码如下 |
复制代码 |
if(strstr($_SERVER["HTTP_USER_AGENT"],"MSIE")==false) {
header("Cache-Control: no-cache");
header("Pragma: no-cache");
}
header('Cache-Control: public, must-revalidate, max-age=0');
header('Accept-Ranges: bytes');
header("Content-Type: application/force-download");
header("Content-Type: application/download");
header("Content-Type: application/octet-stream");
if(!empty($content_type)){
header("Content-Type: ".$content_type);
}
header("Content-Transfer-Encoding: binary");
header('Content-Disposition:attachment;filename="'.rawurlencode($filename).'"');
|
|
Copy code |
|
if(strstr($_SERVER["HTTP_USER_AGENT"],"MSIE")==false) {
header("Cache-Control: no-cache");
header("Pragma: no-cache");
}
header('Cache-Control: public, must-revalidate, max-age=0');
header('Accept-Ranges: bytes');
header("Content-Type: application/force-download");
header("Content-Type: application/download");
header("Content-Type: application/octet-stream");
if(!empty($content_type)){
header("Content-Type: ".$content_type);
}
header("Content-Transfer-Encoding: binary");
header('Content-Disposition:attachment;filename="'.rawurlencode($filename).'"');
http://www.bkjia.com/PHPjc/632115.htmlwww.bkjia.com
trueTechArticleWhen using php header to download files, it always prompts that it cannot be downloaded under IE6, and Google Chrome is normal, so it should It's a problem with IE. There is a bug in IE, and the official Microsoft website explains it. Error message...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn