Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP curl_setopt() CURLOPT_PROGRESSFUNCTION

Tags:

php

curl

i see in the curl_setopt() documentation that you can set a callback function to display the progress of a curl_exec. There's not much said on how the callback function is used. Does anyone know? I'd just like to output the percentage of the file which has been downloaded to STDOUT. Thanks.

like image 791
The Mythical Bird Avatar asked Nov 25 '25 09:11

The Mythical Bird


1 Answers

This is how the callback looks in C:

typedef int (*curl_progress_callback)(void *clientp,
                                      double dltotal,
                                      double dlnow,
                                      double ultotal,
                                      double ulnow);

Probably in PHP it should look like

curl_progress_callback($clientp, $dltotal, $dlnow, $ultotal, $ulnow)

I suppose that dl stands for download and ul for upload.

like image 55
Andrei Bozantan Avatar answered Nov 26 '25 23:11

Andrei Bozantan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!