Php
$file _name = "shunping. jpg";
$file _name=iconv ("GB2312", "GBK", $file _name);//error .... Can you help me change it?
if (!file_exists ($file _name))
{
echo "file does not exist";
return;
}
$fp = fopen ($file _name, "R");
$file _size = filesize ($file _name);
$fp = fopen ($file _name, "R");
Get the size of the download file
$file _size = filesize ($file _name);
The returned file
Header ("Content-type:application/octet-stream");
Returns by byte size
Header ("Accept-ranges:bytes");
Return file size
Header ("Accept-length: $file _size");
Here the client's popup dialog box, corresponding to the file name
Header ("content-disposition:attachment; Filename= ". $file _name);
Loopback data to the client
$buffer = 1024;
In order to download security, we'd better make a file byte read counter
$file _count = 0;
This sentence is used to determine whether the file ends
while (!feof ($fp) && ($file _size-$file _count>0))
{
$file _data = fread ($fp, $buffer);
//统计读了多少个字节 $file_count+=$buffer; //把部分数据回送给浏览器 echo $file_data;} fclose($fp);
?>