Hi,
I am a PHP newbie and trying to add a progress-bar to an existing PHP script using the following method :
$ch=curl_init() or die("ERROR|<b>Error:</b> cURL Error");
curl_setopt($ch, CURLOPT_URL, $c);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_FILE, $fp);
//####################################################//
// This is required to curl give us some progress
// if this is not set to false the progress function never
// gets called
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
// Set up the callback
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'callback');
// Big buffer less progress info/callbacks
// Small buffer more progress info/callbacks
curl_setopt($ch, CURLOPT_BUFFERSIZE, 128);
//####################################################//
curl_exec($ch);
curl_close($ch);
fclose($fp);
The callback function :
function callback($download_size, $downloaded, $upload_size, $uploaded)
{
$percent=$downloaded/$download_size;
// Do something with $percent
echo "$percent";
}
Now, I had literally copy-pasted this example from PHP site but this is not working ?? My PHP version is 5.2.11, Pls. suggest what could be wrong ??
Edit : I am calling this php script from another script.
Information : I am stuck with 5.2.X branch as my web-host says cPanel does not support the 5.3.x branch yet, any solutions for this ??