龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

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

时间:2012-12-24 21:59来源:未知 作者:admin 点击:
分享到:
header函数在php中用处很多,下面我来介绍利用php中的header函数下载文件是中文在不同浏览器筹码的解决办法。 在下载文件中加入下段代码即可解决 代码如下 $name = rawurlencode($filename); h
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");


精彩图集

赞助商链接