This article mainly introduces the cross browser php download file name in Chinese garbled problem solving method, involving PHP for Chinese code transcoding skills, with a certain reference value, the need for friends can refer to the
This article is an example of a cross browser php download file name in Chinese garbled problem solving method. Share to everyone for your reference. Specifically as follows:
The code is as follows: <?php
$ua = $_server["Http_user_agent"];
$filename = "Chinese 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 ';
?>
I hope this article will help you with your PHP program design.