| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| NamePros Regular | PHP cURL Progress Meter 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? Cheers
__________________ -Beaver6813.com V5 Soon! |
| |
| | #2 (permalink) |
| Senior Member | 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.
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| |
| | #3 (permalink) |
| NamePros Regular | 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?
__________________ -Beaver6813.com V5 Soon! |
| |
| | #4 (permalink) |
| Senior Member | cURL isn't for a user initiating a transfer such asfrom a form. cURL is for servers to intiate a transfer.
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| |
| | #5 (permalink) |
| NamePros Regular | 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. :-)
__________________ -Beaver6813.com V5 Soon! |
| |
| | #6 (permalink) |
| Senior Member | 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
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| |
| | #7 (permalink) |
| Senior Member | 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.
__________________ Hacksar.com - Your source for random computer tips and tricks! MySiteMemberships.com - Keep track of your site registration information! Like my post? Rep is appreciated! |
| |
| | #8 (permalink) |
| NamePros Regular | 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?
__________________ -Beaver6813.com V5 Soon! |
| |
| | #9 (permalink) |
| NPQ's PA, Slave, and On Call Coder Technical Services | 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-developm...king-in-php52/
__________________ |
| |
| | #10 (permalink) | |
| Senior Member | Quote:
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft | |
| |
| | #11 (permalink) | |
| NamePros Regular | Quote:
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
__________________ -Beaver6813.com V5 Soon! Last edited by beaver6813; 08-27-2008 at 05:37 PM. | |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |