Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.