解决PHP文件(word/excel)下载 内容打开乱码问题
编码转换不一定有用,一般可以解决文件名乱码问题
iconv('utf-8','gb2312',$filename);
具体代码如下:
header("Pragma: public"); header("Cache-control: max-age=".$expire); //header('Cache-Control: no-store, no-cache, must-revalidate'); header("Expires: " . gmdate("D, d M Y H:i:s",time()+$expire) . "GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s",time()) . "GMT"); header("Content-Disposition: attachment; filename=".$showname); header("Content-Length: ".$length); header("Content-type: ".$type); header('Content-Encoding: none'); header("Content-Transfer-Encoding: binary" );//********************************** ob_clean(); flush();//********************************* readfile($filename);
注意上面的两行代码
ob_clean();flush();参考:http://gaoke0820.blog.163.com/blog/static/216649652013152945362/?suggestedreading&wumii

浙公网安备 33010602011771号