PHP solution Browser Download file Chinese name garbled problem--compatible with most browsers
function SendFile ($serverPath, $filename, $charset = ' UTF-8 ', $mimeType = ' Application/octet-stream ') {//filename garbled problem if (preg _match ("/msie/", $_server["Http_user_agent"])) {$filename = UrlEncode ($filename); $filename = Str_replace ("+", "%20", $ filename);//Replace space $attachmentheader = "content-disposition:attachment; Filename=\ "{$filename}\"; charset={$charset} ";} else if (Preg_match ("/firefox/", $_server["Http_user_agent"])) {$attachmentHeader = ' content-disposition:attachment; Filename*= "Utf8\". $filename. '"' ;} else {$attachmentHeader = "content-disposition:attachment; Filename=\ "{$filename}\"; charset={$charset} ";} $filesize = FileSize ($serverPath);//header ("Pragma:public"); Header ("expires:0"), Header ("Cache-control:must-revalidate, Post-check=0, pre-check=0"), Header ("Content-type: Application/force-download "), Header (" Content-type: {$mimeType} "), header ($attachmentHeader), header (' Pragma: Cache '), header (' Cache-control:public, must-revalidate, max-age=0 '); Header ("Content-length: {$fiLesize} "); ReadFile ($serverPath); exit;}
?