The PDF file in the server is healthy: Verified by direct FTP download.
Some of the code for the downloader is as follows:
$file _size = filesize ($filedir);
Header ("content-type:application/octet-stream;charset=iso-8859-1");
Header ("Cache-control:private");
Header ("Accept-ranges:bytes");
Header ("Accept-length:". $this->fjsize);
Header ("content-disposition:attachment; Filename= ". $this->delfilename);
$fp = fopen ($filedir, "R");
$buffer _size = 1024;
$cur _pos = 0;
while (!feof ($fp) && $filedir-$cur _pos > $buffer _size)
{
$buffer = Fread ($fp, $buffer _size);
Echo $buffer;
$cur _pos + = $buffer _size;
}
if ($file _size > 0)
$buffer = Fread ($fp, $file _size-$cur _pos);
Else
$buffer = Fread ($fp, $this->fjsize);
Echo $buffer;
Fclose ($FP);
Flush ();
Reply to discussion (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
According to the moderator said changed. The error still occurs.
PS: The program has been working well in the past year and has only gone wrong in recent days.
uploaded a file with the following content
1234567890
Abcdefghijklmnopqrstuvwxyz
Then download to local and the results are as follows
? 2426153 Vanadium 4 stunt jljnimk first-step turbulence/(, *.) -+?? ?? ?? &