I have a generic script which is used to return files back to the user. I've tried several different methods of passing files back but none of them can deal with large files.
The code I'm currently using is:
header('Content-length: $size');
header('Content-type:application/octet-stream');
header("Content-Disposition:attachment; filename=$filename");
$fp=fopen("$location","rb");
fpassthru($fp);
fclose($fp);
I've also tried replacing the last 3 lines with:
readfile("$location");
which makes no difference.
Files seem to be okay up until around 10MB, then I start having problems. All files appear to be downloading normally until after a while the browser just gives up and writes the file to disk, incomplete.
Has anyone else had a similar problem and perhaps knows some kind of workaround? Providing direct links to files isn't an option.
Thanks