Skip to content

Instantly share code, notes, and snippets.

@ndunks
Created October 27, 2017 05:02
Show Gist options
  • Save ndunks/778c7efad0956e0f99deae73c52e718f to your computer and use it in GitHub Desktop.
Save ndunks/778c7efad0956e0f99deae73c52e718f 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);
@downloadvideo
Copy link

Support me how to use

@ndunks
Copy link
Author

ndunks commented May 5, 2020

Just change the $url and $to_file, then run it from console or from browser..

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