I thought I had an issue where fread() would fail on files > 30M in size. I tried a file_get_contents() method with the same results. The issue was not reading the file, but echoing its data back to the browser.
Basically, you need to split up the filedata into manageable chunks before firing it off to the browser:
<?php
$total = filesize($filepath);
$blocksize = (2 << 20); $sent = 0;
$handle = fopen($filepath, "r");
header('Content-type: '.$content_type);
header('Content-Disposition: attachment; filename='.$filename);
header('Content-length: '.$filesize * 1024);
while($sent < $total){
echo fread($handle, $blocksize);
$sent += $blocksize;
}
exit(0);
?>
Hope this helps someone!