0

I want to server begins to download a big file. But while this file is downloading output the file content to the user. I tried this code:

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 155000);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$response = curl_exec($ch); // get curl response
echo $response;

But this code takes a long time. I want to use curl instead of readfile.

Ayxan
  • 13
  • 1
  • 8

1 Answers1

0

See this answer: Manipulate a string that is 30 million characters long

Modifing the MyStream class should change it enough so that you can just echo the results to the browser. Assuming the browser is already downloading the file, it should just keep downloading it.

Community
  • 1
  • 1
user3105700
  • 365
  • 5
  • 16