In the past, I have done this:
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
flush()
log()
exit;
the log should only be started after the file has finished reading, which means that the entire file has been transferred to the user. Some time has passed since I did this, and I donβt know where exactly the exact code is, so it may be inaccurate, but it should force you.
EDIT php.net, , , .