I'm using a PHP script to force the download of files (i.e. to stop them opening in a web browser). However with any file larger than about 100k - the file stops at 99% for about 10-20 seconds, before it completes.
Any idea why this could happen? Code below...
$saveasname = basename($filename);
Header('Content-Length: '.filesize($filename));
Header('Content-Type: application/octetstream');
Header('Content-Type: application/force-download');
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=\"".$saveasname."\"");
// Output file
readfile($filename);