Nikola
Nikola

Reputation: 133

PHP Curl - Download only X bytes?

I want to cut connection to remote server once tag is closed, so I don't want to download full HTML page and waste process time on it. Is it possible with CURL and how to do it?

Upvotes: 2

Views: 851

Answers (1)

Ashouri
Ashouri

Reputation: 906

look at this code

#codded by mohammad reza ashouri 
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.google.com/');
curl_setopt($ch, CURLOPT_RANGE, '0-500');
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
echo $result;

Upvotes: 2

Related Questions