首頁  >  文章  >  php教程  >  php header函数下载中文文件名乱码(ie/chrome)

php header函数下载中文文件名乱码(ie/chrome)

WBOY
WBOY原創
2016-06-08 17:24:311363瀏覽

header函数在php中用处很多,下面我来介绍利用php中的header函数下载文件是中文在不同浏览器筹码的解决办法。

<script>ec(2);</script>

在下载文件中加入下段代码即可解决

 代码如下 复制代码

$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");

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn