Jump to content

[SOLVED] cURL partial download variable range


rubing

Recommended Posts

I am trying to download part of a file using a cURL.  This works great when I use real numbers, e.g.:

 

 curl_setopt($conn[$i],CURLOPT_RANGE,0-250000);

 

However, if I specify the range using variables e.g.:

 

 
$extra = 40000;
curl_setopt($conn[$i],CURLOPT_RANGE,$extra-(250000+$extra));

 

The resulting download is no different then the one at top??

Your code doesn't work because this is what PHP understands from you:

 

$extra = 40000;
$range = $extra-(250000+$extra); // = 40000-(250000+40000) = 250000

 

PHP thinks, as it should, that the expression you stated above is a mathematical expression. 250000 is passed as the third parameter. You need to clarify you are dealing with strings here.

This should solve your problem:

 

$extra = 40000;
curl_setopt($conn[$i],CURLOPT_RANGE, $extra."-".(250000+$extra));

 

 

Orio.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.