header函數在php中用處很多,下面我來介紹利用php中的header函數下載文件是中文在不同瀏覽器籌碼的解決辦法.
在下載文件中加入下段代碼即可解決,代碼如下:
- $name = rawurlencode($filename);
- header("Content-type: text/plain; charset=utf-8");
- header("Content-Type: application/force-download");
- header("Content-Type: application/octet-stream");
- header("Content-Type: application/download");
- header('Content-Disposition:inline;filename="'.$name.txt.'"');
- header("Content-Transfer-Encoding: binary");
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
- header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
- header("Pragma: no-cache");
新聞熱點
疑難解答