php cURL progress monitor? php cURL progress monitor? curl curl

php cURL progress monitor?


Assuming you're using PHP >=5.3 (previous versions do not support CURLOPT_PROGRESSFUNCTION) you use it like so:

function callback($download_size, $downloaded, $upload_size, $uploaded){    // do your progress stuff here}$ch = curl_init('http://www.example.com');// This is required to curl give us some progress// if this is not set to false the progress function never// gets calledcurl_setopt($ch, CURLOPT_NOPROGRESS, false);// Set up the callbackcurl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'callback');// Big buffer less progress info/callbacks// Small buffer more progress info/callbackscurl_setopt($ch, CURLOPT_BUFFERSIZE, 128);$data = curl_exec($ch);

Source: http://pastebin.com/bwb5VKpe