Skip to content

Instantly share code, notes, and snippets.

@aznoisib
Forked from ndunks/downloader.php
Created January 1, 2021 21:09
Show Gist options
  • Save aznoisib/5589f8728f55eedf6f1c3317d3f43daf to your computer and use it in GitHub Desktop.
Save aznoisib/5589f8728f55eedf6f1c3317d3f43daf to your computer and use it in GitHub Desktop.
PHP Curl Downloader with resume support
<?php
set_time_limit(0);
ignore_user_abort(true);
$url = "http://web.shit/backup.zip";
$ch = curl_init($url);
$to_file = 'web.zip';
$opt = array();
if(is_file($to_file))
{
$sz = filesize($to_file);
$opt[CURLOPT_RANGE] = $sz . "-";
}
$opt[CURLOPT_SSL_VERIFYPEER]= false;
$opt[CURLOPT_FILE] = fopen($to_file, 'a');
$opt[CURLOPT_USERAGENT] = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36';
curl_setopt_array($ch, $opt);
curl_exec($ch);
$grab_info = curl_getinfo($ch);
fclose($opt[CURLOPT_FILE]);
print_r($grab_info);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment