php-php can only download the English name of the picture, can not download Chinese named pictures How to do?

Source: Internet
Author: User
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)!

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.