There may be a problem with the downloader code, causing the PDF file to be corrupted
Source: Internet
Author: User
There may be a problem with the downloader code, causing the PDF file to become corrupted
The PDF file in the server is healthy: Verified by direct FTP download.
Some of the code for the downloader is as follows:
if ($file _size > 0)
$buffer = Fread ($fp, $file _size-$cur _pos);
Else
$buffer = Fread ($fp, $this->fjsize);
Echo $buffer;
Fclose ($FP);
Flush ();
------Solution--------------------
$fp = fopen ($filedir, "R b"); Binary mode open, although Linux is not required, but still recommended to do so
Text Open file, 0x1a is considered the end of the file
while (!feof ($fp) && $filedir-$cur _pos > $buffer _size)
Writing
while (!feof ($FP))
Feof ($FP) is the end of the file.
Again $filedir-$cur _pos > $buffer _size no need
Double judgments can lead to errors, such as $filedir not $buffer _size integer times
In addition, you cannot export anything other than the contents of the file, including the BOM header
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.