";
echo "Loading ...";
$url=isset($_GET['file'])? $_GET['file']:'http://upload.wikimedia.org/wikipedia/commons/c/cf/Frog_on_river_4000x3000_26-09-2010_11-01am_2mb.jpg';
$file = fopen($filename,'w');
ob_flush();
flush();
ignore_user_abort(true);
function progress1($download_size, $downloaded, $upload_size, $uploaded)
{
if($download_size > 0){
$percent = intval($downloaded / $download_size * 100)."%";
echo '';
}
ob_flush();
flush();
// sleep(3); // just to see effect
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_BUFFERSIZE,64000);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE); //not cache
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FILE, $file);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'progress1');
curl_setopt($ch, CURLOPT_NOPROGRESS, false); // needed to make progress function work
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
$html = curl_exec($ch);
curl_close($ch);
echo '';
ob_flush();
flush();
?>