Skip to content

Instantly share code, notes, and snippets.

@lmammino
Created December 21, 2012 15:15
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save lmammino/4353399 to your computer and use it in GitHub Desktop.
Save lmammino/4353399 to your computer and use it in GitHub Desktop.
Download a large file (streaming) with php and curl extension
<?php
$url = 'http://www.example.com/a-large-file.zip';
$path = '/path/to/a-large-file.zip';
$fp = fopen($path, 'w');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
$data = curl_exec($ch);
curl_close($ch);
fclose($fp);
@kicktv
Copy link

kicktv commented May 13, 2020

is work...
thanks

@ShafqatAliRafaqat
Copy link

It worked for small files but if the file is large enough that can be downloaded in 30s then got 504 timeout error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment