php can only download the English name of the picture, can not download the Chinese named image how to do?
Php
<?php function Down_file ($file _name, $file _sub_dir) {$file _name=iconv ("Utf-8", "gb2312", $file _name); $file _path=$_server[' Document_root '). $file _sub_dir. $file _name; if (!file_exists ($file _path)) {echo "file does not exist"; Return } $fp =fopen ($file _path, "R"); $file _size=filesize ($file _path); /*if ($file _size>30) {echo "<script language= ' JavaScript ' >window.alert (' file too large ');</script>"; Return }*/header ("Content-type:application/octet-stream"); Header ("Accept-ranges:bytes"); Header ("Accept-length: $file _size"); Header ("content-disposition:attachment; Filename= ". $file _name); $buffer = 1024; $file _count=0; while (!feof ($fp) && $file _size-$file _count>0) {$file _data=fread ($fp, $buffer); $file _count+= $buffer; echo $file _data; } fclose ($FP); } down_file ("Answer.jpg", "/http/");? >
Successful download, open successfully:
Then I put the last sentence in the filedown.php file of the first picture.
Down_file ("Answer.jpg", "/http/");
Change into
Down_file ("answer. jpg", "/http/");
And in the site to change the name of the picture from "answer.jpg" to "answer. JPG", I re-refresh the address:
http://localhost/http/fileDown.php
As a result it gives me a popup dialog box:
Why is the file name not "answer. jpg"? The last download is not a picture ah.
What is the reason, please?
Reply content:
Http://www.php.cn/php-weizijiaocheng-300416.html
I brainwave, cut the code in the filedown.php file into the EditPlus editor, and then save it to the same location in the site, using the original notepad++ Editor edited by the filedown.php file to cover, this time not only to successfully download, but also open the picture successfully. Make a day, only found that the original is notepad++ editor problem Ah! I as a beginner, unexpectedly can discover notepad++ This world famous editor bug, everybody wants excitedly spread, warning AH! Hey.
By the way, the above picture is the answer I wrote to the following question, everyone who has the ph. D. math Forum account, trouble to help this poor brother.
Or any of you who have unnecessary account, send one to me.
http://www.math.org.cn/forum.php?mod=viewthread&tid=37021
The above is php-php can only download the English name of the picture, can not download Chinese named pictures How to do? For more information, please pay attention to topic.alibabacloud.com (www.php.cn)!