php下载word或doc出现乱码问题
- 日期 : 2015-10-06
1.首先检查编码是否一致
php下载word或doc时,出现乱码问题,我的php和word都是统一utf-8编码,所以不存在编码问题.
2.检查php下载文件前是否有缓存输出,主要看下面代码红色处,在输出下载文件前,先清除下缓存.
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$dname.'"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
ob_clean();
flush();
readfile($fpath . $fname);
php下载word或doc时,出现乱码问题,我的php和word都是统一utf-8编码,所以不存在编码问题.
2.检查php下载文件前是否有缓存输出,主要看下面代码红色处,在输出下载文件前,先清除下缓存.
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$dname.'"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
ob_clean();
flush();
readfile($fpath . $fname);