Practice php file Upload, upload pictures cannot open
Source: Internet
Author: User
Practice php File Download, download the picture does not open
$file _name= "Hello.jpg";
if (!file_exists ($file _name))
{
echo "file does not exist";
Return
}
$FP =fopen ($file _name, "R");
Get the download file size
$file _size=filesize ($file _name);
echo $file _size;
The returned file
Header ("Content-type:application/octet-stream");
Returns by byte size
Header ("Accept-ranges:byte");
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);
$buffer = 1024;
Determine whether the file ends at the end
while (!feof ($FP))
{
echo "1111";
$file _data=fread ($fp, $buffer);
Send some data back to the browser
echo $file _data;
}
Fclose ($FP);
?>
The prompt to open the picture file is: Because this file may be corrupted, or too large
------Solution--------------------
echo $file _size; This sentence is commented out
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