一般来说,下载txt会直接打开,把下面的代码放入到下载页面中,就不会了!
1 | //下载$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); |
新闻热点
疑难解答