>  기사  >  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으로 문의하세요.