TheCracker
02-26-2012, 05:56 AM
Hello,
i have special case of resuming download, the file is not on server. the file is located at remote server, let's say
http://server/file.zip
and i'm using ranged curl to fetch the file and echo it on user's browser
header('Cache-control: private');
header('Content-Type: application/octet-stream');
header('Content-Length: '.$filesize);
header('Content-Disposition: filename=name');
$end_range = $filesize;
while($start_range <= $end_range) {
if(($start_range + 9999999) > $end_range) $range = $start_range.'-'.$end_range;
else $range = $start_range.'-'.($start_range + 9999999);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url2);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');
curl_setopt($ch, CURLOPT_RANGE,$range);
curl_exec($ch);
curl_close($ch);
$start_range +=10000000;
flush();
}
what should i change in code so that the user will be able to resume the download??
i have special case of resuming download, the file is not on server. the file is located at remote server, let's say
http://server/file.zip
and i'm using ranged curl to fetch the file and echo it on user's browser
header('Cache-control: private');
header('Content-Type: application/octet-stream');
header('Content-Length: '.$filesize);
header('Content-Disposition: filename=name');
$end_range = $filesize;
while($start_range <= $end_range) {
if(($start_range + 9999999) > $end_range) $range = $start_range.'-'.$end_range;
else $range = $start_range.'-'.($start_range + 9999999);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url2);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');
curl_setopt($ch, CURLOPT_RANGE,$range);
curl_exec($ch);
curl_close($ch);
$start_range +=10000000;
flush();
}
what should i change in code so that the user will be able to resume the download??