===== PHP download function =====& lt ;? Phpheader ('content-type: & nbsp; video/mpeg4'); // output type header ('content-Disposition: & nbsp; attachment; & nbsp; filename = "file name .mp4" '===== PHP download function ====
Header ('content-type: video/mpeg4'); // output type
Header ('content-Disposition: attachment; filename = "file name .mp4" '); // name displayed for download
Readfile('file name .mp4 ');
?>
This is a piece of download code for my use.
However, when the file name is in Chinese, the name displayed in the Download box and after the download is garbled.
Is PHP not recognizing Chinese characters in this download function?
How can I modify the PHP download function to download files with Chinese names? Php header download
------ Solution --------------------
Whether garbled characters are displayed depends on the default character set of the user's operating system.
------ Solution --------------------
Header ("Content-type: text/html; charset = utf-8 ");
------ Solution --------------------
Url_encode transcodes the file name before executing the download program.
------ Solution --------------------
The two upstairs are here to disturb the situation ~
------ Solution --------------------
You can check the php file format. the file format is consistent with the code encoding format. otherwise, garbled characters will occur.
If your php file is utf8, add the header ("Content-type: text/html; charset = utf-8"); top
------ Solution --------------------
You can try transcoding your downloaded file name iconv ().