Echo the progress of a file_put_contents command

Hi there,

I’m using file_put_contents to download files to my server, but can’t find a way to show real time progress.

I have the file size, and as far as I can see, file_put_contents will return how many bytes that have been downloaded, but I can’t access that info in real time.

So in short - how would I get the bytes downloaded by file_put_contents and display them on a HTML page?

Cheers!

Well, there are many ways to handle this. PHP has a stream-callback system that should work.
Here is a link to PHP’s manual that explains it. Just scroll down to the samples and you will see how
it works and one of the callbacks is a display for progess…

Try it and let us know how it works out…

http://php.net/manual/en/function.stream-notification-callback.php

Sponsor our Newsletter | Privacy Policy | Terms of Service