Skip to content

Instantly share code, notes, and snippets.

@rcg4u
Forked from lmammino/curlStreamedDownload.php
Created January 19, 2022 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcg4u/31c999141a4df4cee64d449d2788f52e to your computer and use it in GitHub Desktop.
Save rcg4u/31c999141a4df4cee64d449d2788f52e 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment