-
-
Save shakahl/b519d3a3954d22ac1740 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* Using CURL to download partial content from a URL | |
* | |
* @url file URL to download | |
* @range_start Start range in bytes | |
* @range_end End range in bytes | |
* | |
* | |
* example: curl_get_content("http://www.example.org/some-file.zip",100,500) | |
* | |
**/ | |
function curl_get_content($url,$range_start,$range_end) | |
{ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt ($ch, CURLOPT_HTTPHEADER, array ("Range: bytes=$range_start-$range_end")); | |
$data = curl_exec($ch); | |
curl_close($ch); | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment