cURL Download Progress in PHP not working? cURL Download Progress in PHP not working? curl curl

cURL Download Progress in PHP not working?


There doesn't seem to be a CURLOPT_PROGRESSFUNCTION before php 5.3.

Take a look at http://cvs.php.net/viewvc.cgi/php-src/ext/curl/interface.c?view=log and you will find two entries - [DOC] MFH: #41712, implement progress callback. One for the php5.3 and one for the php6 branch.

edit: With php 5.2.x you should be able to set a stream_notification_callback

function foo() {  $args = func_get_args();  echo join(', ', $args), "\n";}$ctx = stream_context_create(null, array('notification' =>'foo'));$fpIn = fopen('http://php.net/', 'rb', false, $ctx);file_put_contents('localfile.txt', $fpIn);


Regarding the last comment, said code requires 5.3 because stream_context_create()'s second parameter was added in 5.3. However, replacing that line with the following works in 5.2:

$ctx = stream_context_create();stream_context_set_params($ctx, array("notification" => "stream_notification_callback"));

And in related news, the stream_notification_callback() documentation within the PHP manual has an example that fully utilizes/creates a progress bar, so check it out.

http://php.net/stream_notification_callback