[php] $filename = '中文.doc'; $filename = urlencode($filename); echo $filename; echo "<a href='download.php?filename=".$filename."'>下载</a>"; ?> [/php] download.php: [php] <?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); ?> [/php] 好吧 就这样 睡觉了。。ZZZZ
在php的下载上遇到了下载中文文件乱码的问题 记录一下代码:
test.php:
转载于:https://www.cnblogs.com/iamchao/p/3677157.html