This is weird .
I have a script that sends local zip files to a user through a browser. The script works fine so far without any problems. Today my colleague informed me that the script is sending files of zero length.
Some background information:
- Server settings were not changed before the script went wrong.
- Various browsers checked (same in Chrome / Firefox)
- Previous zip files (which worked just fine before) also have zero length.
- Script finds files on the server
- Is the file size correct (when echoing for debugging)
- I tried to configure the server and script settings as here without success.
UPDATE:
is_readable() returns 1- file size can vary from 5 MB to 100 MB (undefined)
$zip_file contains file path$zip_name contains the name zip- the file really has zero length (opened in a text editor, it does not contain one byte)
error_reporting On( E_ALL) shows nothing- without headers, the browser correctly displays the source "zip"
- Safari says: " 0 bytes? Can't decode source data 'first useful (?) Symptom
The fragment in question:
if (file_exists($zip_file)) {
header('Content-type: application/zip');
header('Content-disposition: filename="' . $zip_name . '"');
header("Content-length: " . filesize($zip_file));
readfile($zip_file);
exit();
}
How can I easily debug this?
Thanks in advance, fabrik
source
share