Home > Article > Backend Development > PHP about downloading Chinese files
本篇文章和大家分享了php 关于下载中文文件实现 ,有需要的朋友可以参考一下
在php的下载上遇到了下载中文文件乱码的问题
记录一下代码:
test.php:
$filename = '中文.doc'; $filename = urlencode($filename); echo $filename; echo "<a href='download.php?filename=".$filename."'>下载</a>";
?>
download.php:
$filename = $_REQUEST['filename']; <strong>$filename = iconv('utf-8', 'gb2312', $filename);</strong> // 这是最关键的一句,我原以为urlencode以后就不用转格式了。 header("Content-Type: application/octet-stream;"); header('Content-Disposition:attachment;filename=' .$filename); readfile($filename);
好吧 就这样 睡觉了。。ZZZZ
The above is the detailed content of PHP about downloading Chinese files. For more information, please follow other related articles on the PHP Chinese website!