Im trying to download a file directly to the client browser using CURL like this:
This does work and downloads file to client browser. But with a quite a delay after its run. I noticed that when i start it runs download in the background probably saving it to some temporary file or in ram memory not sure and then when download is complete it outputs it to client browser for download.
I'm trying to avoid this unessesary delay, can anyone help me and point out what Im doing wrong here?
Code:
header([COLOR=#800000]'Content-Type: application/force-download'[/COLOR]);
header([COLOR=#800000]'Content-Disposition: attachment; filename="'[/COLOR].$filename.[COLOR=#800000]'"'[/COLOR]);
header([COLOR=#800000]'Content-Length: '[/COLOR].filesize[COLOR=#800000]');
$chdownload = curl_init();
curl_setopt($ch, CURLOPT_URL, $url]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
echo $data;[/COLOR]
This does work and downloads file to client browser. But with a quite a delay after its run. I noticed that when i start it runs download in the background probably saving it to some temporary file or in ram memory not sure and then when download is complete it outputs it to client browser for download.
I'm trying to avoid this unessesary delay, can anyone help me and point out what Im doing wrong here?