PHP Download Chinese pictures error problem

Source: Internet
Author: User
Keywords Php
Tags php download
Php

Run on a different page he will report the downloaded image without the error but my picture exists
The name of the English picture can be but the name of the Chinese image of the paper does not exist why? Help to correct ....
The showpicture.php page is as follows:




Untitled Document


Click to download
Click to download

$str = UrlEncode ("shunping. jpg");
echo "Click to download"
?>
Click to download


The downpicture.php page is as follows:
Header ("Expires:-1");
Header ("Cache-control:no_cache");
Header ("Pragma:no-cache");
Header ("content-type:text/html; Charset=utf-8 ");
Require ' class/filedown.class.php ';
$name =urldecode ($_request["name"]);
Echo $name;
Down_file ($name, "/mianxiangduixiang/down/");
?>
The fileDown.class.php page is as follows:
Header ("Expires:-1");
Header ("Cache-control:no_cache");
Header ("Pragma:no-cache");
Header ("content-type:text/html; Charset=utf-8 ");
function Down_file ($file _name, $file _sub_dir)
{
$file _name=iconv ("gb2312", "GBK", $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);
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);
}
?>
  • 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.