帝国CMS强制下载txt文件浏览器带下载进度显示
2024-09-07
浏览器下载txt会直接打开,把下面的代码放入到下载页面中,就提示下载并可以进度保存了!文件位置(\e\DownSys\class\DownSysFun.php)
找到如下代码(帝国CMS7.5 大概203行左右)
//下载
Header(Content-type: application/octet-stream);
//Header(Accept-Ranges: bytes);
//Header(Accept-Length: .$filesize);
Header(Content-Disposition: attachment; filename=.$filename);
echo ReadFiletext($file);
改成如下代码:(注意UTF8编码请用编辑器打开修改) //下载 $filesize = filesize($file); Header('Pragma: public'); Header('Last-Modified:'.gmdate('D, d M Y H:i:s') . ' GMT'); Header('Cache-Control: no-store, no-cache, must-revalidate'); Header('Cache-Control: pre-check=0, post-check=0, max-age=0'); Header('Content-Transfer-Encoding: binary'); Header('Content-Encoding: none'); Header(Content-type: application/octet-stream); Header(Content-Disposition: attachment; filename=.$filename); Header('Content-length: '.$filesize); echo ReadFile($file);
声明:本文来自用户分享和网络收集,仅供学习与参考,测试请备份。