07-09-2012, 09:31 PM
Join Date: May 2011
|I have 2 servers, 1 for running PHP apps and database, 1 for streaming and download medium static files.
I was using this line of PHP code to handle download.
It's good in performance but lacking of convenience for my users, IE users must Save target as..., or browsers auto-handle this with their inline media player.
header('Location: ' . $external_media_url);
I've searched around the internet for a coupe of hours, but everyone is using these line of codes for their download feature.
This works GREAT, but i see an impact to client's speed rate and long processing time to serve a download, because it must read entire filesize in the external server and re-buffer to serve client.
$filename = basename($url).PHP_EOL;
$filesize = getRemoteFileSize($url);
header('Content-Description: File Transfer');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Disposition: attachment; filename =' . $filename);
header('Content-Length: ' . $filesize);