rubing Posted June 16, 2008 Share Posted June 16, 2008 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?? Link to comment https://forums.phpfreaks.com/topic/110486-solved-curl-partial-download-variable-range/ Share on other sites More sharing options...
Orio Posted June 16, 2008 Share Posted June 16, 2008 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. Link to comment https://forums.phpfreaks.com/topic/110486-solved-curl-partial-download-variable-range/#findComment-566858 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.