跨浏览器,PHP,下载文件,中文乱码,解决方法
php教程-PHP源码本文实例讲述了跨浏览器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’;
?>
淘宝复制软件源码,自己写vscode插件,ubuntu xz下载,java导入tomcat包,湖北爬虫,php博客项目开发,日照谷歌seo营销公司,创业加盟网站源码,html5手机移动端模板lzw
易语言999朵心形玫瑰源码,vscode查看大纲,ubuntu的go语言更新频率,如何请求tomcat,sqlite更新表约束,php插件模板代码下载,前端的框架都有哪些,梦见捡爬虫皮,服务器支持php,seo真名,宗师堂网站源码,个人软件下载网页源码,网站带支付模板,导航laysns程序源码lzw
复制代码 代码如下:在线租车源码,vscode 代码层级插件,ubuntu 安装rsa,tomcat 类加载时机,C爬虫与Java爬虫的区别,php 读入文件,滨江seo推广多少钱,彩票网站系统源码,教育网站模板下载lzw
<?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执行Curl时报错提示CURL ERROR: Recv failure: Connection reset by peer的操作 | PHP执行Curl时报错提示CURL ERROR: Recv failure: Connection reset by peer的操作 ...
PHP执行Curl时报错提示CURL ERROR: Recv failure: Connection re【PHP】 | PHP执行Curl时报错提示CURL ERROR: Recv failure: Connection re【PHP】 ...