I would like to execute the callback function every X bytes uploaded, but I don't understand why php keeps calling the callback function way way more often.
here is my code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$converter);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'callback');
curl_setopt($ch, CURLOPT_BUFFERSIZE, 10485764);
$result=curl_exec ($ch);
//$info = curl_getinfo($ch);
//print_r($info);
curl_close ($ch);
function callback($resource, $download_size, $downloaded, $upload_size, $uploaded) {
echo $uploaded . '/' . $upload_size ."";
}
The file to upload is around 68 MB, the callback function should get executed 68 times (10485764 bytes = 1 MB), but it gets executed around 9k times...
The function should write the progress in a mysql db, that's why I need it to get executed less time.