亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

兼容ie6瀏覽器的php下載文件代碼分享

 更新時(shí)間:2014年07月14日 11:21:34   投稿:junjie  
這篇文章主要介紹了兼容ie6瀏覽器的php下載文件代碼分享,解決了ie6下無法下載文件的bug,需要的朋友可以參考下

PS:這段代碼在win系統(tǒng)下跑沒有問題,楓哥親測可用.如果用的是linux或是其他系統(tǒng),要要諸位自行測試下啦.

$filename = "./".$_REQUEST['name']; //這里是楓哥具體路徑,只要$filename是所要下載文件的完整路徑就可以.
if (!is_file($filename)) {//檢測文件是否存在.
 die('下載的文件好像跟TM誰私奔啦!');
}
$filepath = str_replace('\\', '/', realpath($filename));
$filesize = filesize($filepath);
$filename = substr(strrchr('/'.$filepath, '/'), 1);
$extension = strtolower(substr(strrchr($filepath, '.'), 1));
       // use this unless you want to find the mime type based on extension,文件后綴格式,不解釋.
$mime = array('application/octet-stream');
header('Content-Type: '.$mime);
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.sprintf('%d', $filesize));
header('Expires: 0');
// check for IE only headers,坑爹的IE檢測,你懂的.
if (isset($_SERVER['HTTP_USER_AGENT']) &&((strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)))
{
 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
 header('Pragma: public');
}
else
{
 header('Pragma: no-cache');
}
$handle = fopen($filepath, 'rb');
fpassthru($handle);
fclose($handle);

這個(gè)代碼是楓哥從國外的一個(gè)站點(diǎn)上找到的,親測可用.度娘出來的結(jié)果,你懂的.因此在博客上共享出來,希望對大家有用.國外的站,地址忘了,沒有辦法放出,理解下.最后,嚴(yán)肅的聲明下:這個(gè)代碼不是我寫的,是轉(zhuǎn)載的.

相關(guān)文章

最新評論