1

I have a download method from a library that accepts callback function for handling percents of downloaded file.

$cb = function ($percent) {
    echo $percent;
};


$info = $MadelineProto->download_to_dir($messageMediaPhoto, 'assets', $cb);

But it only echos 100 at the end. How can I get the all percents? How can it be done in a blocking io language?

Akshay
  • 3,558
  • 4
  • 43
  • 77
Vahid Najafi
  • 4,654
  • 11
  • 43
  • 88
  • Possible duplicate of [How do I implement a callback in PHP?](http://stackoverflow.com/questions/48947/how-do-i-implement-a-callback-in-php) – M A SIDDIQUI Apr 13 '17 at 10:18
  • Assuming your `download_to_dir` uses curl, take a look at http://stackoverflow.com/questions/13958303/curl-download-progress-in-php Otherwise, for stream functions like `file_get_contents`, you can use http://php.net/manual/en/function.stream-notification-callback.php – Alex Blex Apr 13 '17 at 10:36
  • @AlexBlex Thank you. But until the process is finished, I can't get any percent. I get the whole output once (tested for both linked you provided). How should I send request? – Vahid Najafi Apr 13 '17 at 11:26
  • Well, it was a generic question, if it is possible or not. The answer is yes, it is. If it does not work as expected, it is a debugging kind of a question, which requires an mcve: https://stackoverflow.com/help/mcve. Please update the question with reproducible examples of what you have tried. – Alex Blex Apr 13 '17 at 11:37

1 Answers1

1

This is fixed in the latest version of MadelineProto.

Danogentili
  • 664
  • 7
  • 13