On my site, users can input links to files and I can stream the download process to them through my server. I use a system like this:
header('Cache-control: private');
header('Content-Type: application/octet-stream');
header('Content-Length: ' . $r[2]);
header('Content-Disposition: filename=' . $theName);
flush();
$file = fopen($fileName, "r");
while(!feof($file))
{
print fread($file, 10240);
flush();
sleep(1);
}
fclose($fileName);
The think is, my users downloads go pretty slowly (600kb/s). The server this is hosted on is on a 1Gbit port so they should be maxxing out their internet connection tenfold.
I'm wondering if there is a better way to do this sort of thing, maybe cURL perhaps? I don't have much experience with cURL but I'd appreciate any feedback.
Thanks.