<?
if (is_file("files/".$_GET['file']))
{
$filename = "files/".$_GET['file'];
$handle = fopen($filename, "rb");
$contents = fread($handle, filesize($filename));
$total = filesize($filepath);
$blocksize = (2 << 20); //2M chunks
$sent = 0;
fclose($handle);
// Push headers that tell what kind of file is coming down the pike
header('Content-type: '.$content_type);
header('Content-Disposition: attachment; filename='.$filename);
header('Content-length: '.$filesize * 1024);
// Now we need to loop through the file and echo out chunks of file data
// Dumping the whole file fails at > 30M!
while($sent < $total){
echo fread($handle, $blocksize);
$sent += $blocksize;
}
exit(0);
}
?>