Many users of my site reported problems downloading a large file (80 MB). I use forced loading using headers. If necessary, I can provide additional php settings. I am using CakePHP framework, but this code is regular php. I am using php 5.2 with apache on a dedicated virtual server from the CentOS Linux media temple. You see any problems with the following code:
set_time_limit(1500);
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"" . basename($file_path) . "\"");
header("Content-Length: ".$content_length);
header("Content-Transfer-Encoding: binary");
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Pragma: public');
header('Expires: 0');
$handle = fopen($file_path, 'rb');
while (!feof($handle))
{
echo fread($handle, 4096);
ob_flush();
flush();
}
fclose($handle);
exit;
Basically, the problem is that the download starts and then stops in the middle. I thought this was a limit problem, so I am adding the set_time_limit code. I used to use the php reader function, but that also did not work smoothly.