NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page PHP cURL Progress Meter

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 08-27-2008, 04:44 PM THREAD STARTER               #1 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




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 is offline  
Old 08-27-2008, 04:51 PM   #2 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
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
Peter is offline  
Old 08-27-2008, 05:03 PM THREAD STARTER               #3 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




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 is offline  
Old 08-27-2008, 05:06 PM   #4 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
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
Peter is offline  
Old 08-27-2008, 05:10 PM THREAD STARTER               #5 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




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 is offline  
Old 08-27-2008, 05:13 PM   #6 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
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
Peter is offline  
Old 08-27-2008, 05:28 PM   #7 (permalink)
Senior Member
 
nasaboy007's Avatar
Join Date: Jul 2005
Location: NJ
Posts: 1,219
nasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud of
 



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.
nasaboy007 is offline  
Old 08-27-2008, 05:29 PM THREAD STARTER               #8 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




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 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 is offline  
Old 08-27-2008, 05:31 PM   #9 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
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/
Eric is offline  
Old 08-27-2008, 05:43 PM   #10 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
Originally Posted by SecondVersion
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/
You need to install a pecl extension, failling that the other option is to add an extension to php which of course requires root access
__________________
Manage your portfolio using my new Domain Portfolio Management script.
Securing Your Domain Name From Theft
Peter is offline  
Old 08-27-2008, 05:59 PM THREAD STARTER               #11 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




Originally Posted by SecondVersion
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/
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 by beaver6813; 08-27-2008 at 06:37 PM.
beaver6813 is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 09:36 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger