I am trying to write a script in PHP that downloads a large zip file (2,663,439,370 bytes), and I encountered an interesting but unpleasant problem: the script loads the first 2,147,483,647 bytes, and then continues to load the file, but instead of adding byte number 2.147 to it. 483.648, 2.147.483.649, etc. he continues to add bytes to the file, starting at byte number 1.
Thus, the downloaded file is created from: byte 1, byte 2, ... byte 2.147.483.647, byte 1, byte 2 ... and so on.
I notice that 2.147.483.647 is the maximum integer value that a 32-byte system can store. However, my server is a 64-byte system and can store values ββthat exceed this. To prove this, var_dump ((int) 2147483648) returns the correct integer.
My script loading is as correct as possible (taken from php.net using copy-paste)
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="Certificat.zip"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($zipname));
readfile($zipname);
Has anyone encountered this problem?
source
share