NameSilo

PHP cURL Progress Meter

Spaceship Spaceship
Watch

beaver6813

Established Member
Impact
16
Hey guys,

Just wondering if anyones had any experience with trying to get up a progress meter when using cURL or any other transfer method.
I'm transfering quite large files and need to try get cURL or whatever to output its loading status.. but I really can't figure out how to do it, any ideas anyone... please? :lala:

Cheers
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
to be honest in php I am not aware of any functions that will tell you the progress of the transfer and as php is a single process langauge I dont think it is possible.

If you have access to the system function you could always try using wget and periodically check the output until it is complete.
 
0
•••
Okay thanks, I'm using a combination on my image hosting site that monitors uploads using Perl and PHP, where Perl uploads the file and PHP gets the filesize transfered.. maybe i'll try something like that with cURL.
Do you know if its possible to find out the temporary filename thats created for the transfer?
 
0
•••
cURL isn't for a user initiating a transfer such asfrom a form. cURL is for servers to intiate a transfer.
 
0
•••
Yea I know that but I'm thinking that if the server creates a temporary file to download to then surely I can read the size of that file from an external script. I didn't mean exactly copying the upload script but using the same kind of idea. :)
 
0
•••
but php has no knowledge of how large the file is going to be so would not know what the % is or how complete it is
 
0
•••
one way to have dynamically updating "feedback" would be to use the flush function. it'll output whatever while still going so you can use it to somehow kinda show progress.

although peter is exactly right, php doesnt know the total filesize WHILE it's uploading, so you can't exactly do percentages, etc. you could probably get away with "Processing..." and have something moving though.
 
0
•••
That is very true actually :( Only in PHP 5 can you even get the FTP remote filesize let alone HTTP.. It's just so frustrating that cURL will give a progress meter fine when operated in terminal and wont even write out a status report in PHP :P Thanks for all the info Peter, i'll find a way eventually then post back here :)

EDIT:
Nasaboy007, I thought PHP couldn't continue until the transfer/function had completed, so therefore I wouldn't be able to generate any kind of updating output during download?
 
0
•••
1
•••
0
•••
SecondVersion said:
PHP 5 has 'hooks' that can be used for this purpose. In fact, I believe it's built into APC (the opcode cache). There is also an extension/patch made for it.

http://the-stickman.com/web-development/php/upload-progress-tracking-in-php52/

Very informative, i'll try and get my head around it all, its for a single server that i conveniently have root access to so it makes it a hell of a lot easier! Thanks!

EDIT:
I have just found a way to achieve my original objective with cURL and the use of temporary files, the only requirement is the content-length response header but apart from that its pretty easy, i'll compile a small class and post in the CODE forum soon :)
 
Last edited:
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back