您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

跨浏览器PHP下载文件名中的中文乱码问题解决方法_PHP

2024/4/4 12:44:15发布15次查看
本文实例讲述了跨浏览器php下载文件名中的中文乱码问题解决方法。分享给大家供大家参考。具体如下:
代码如下:
$ua = $_server[http_user_agent];
$filename = 中文 文件名.txt;
$encoded_filename = urlencode($filename);
$encoded_filename = str_replace(+, %20, $encoded_filename);
header('content-type: application/octet-stream');
if (preg_match(/msie/, $ua)) {
    header('content-disposition: attachment; filename=' . $encoded_filename . '');
} else if (preg_match(/firefox/, $ua)) {
    header('content-disposition: attachment; filename*=utf8\'\'' . $filename . '');
} else {
    header('content-disposition: attachment; filename=' . $filename . '');
}
print 'abc';
?>
希望本文所述对大家的php程序设计有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product