[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 08-27-2008, 03:44 PM   #1 (permalink)
NamePros Regular
 
beaver6813's Avatar
 
Join Date: May 2005
Location: England
Posts: 349
65.50 NP$ (Donate)

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.com V5 Soon!
beaver6813 is offline  
Old 08-27-2008, 03:51 PM   #2 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

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, 04:03 PM   #3 (permalink)
NamePros Regular
 
beaver6813's Avatar
 
Join Date: May 2005
Location: England
Posts: 349
65.50 NP$ (Donate)

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.com V5 Soon!
beaver6813 is offline  
Old 08-27-2008, 04:06 PM   #4 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

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, 04:10 PM   #5 (permalink)
NamePros Regular
 
beaver6813's Avatar
 
Join Date: May 2005
Location: England
Posts: 349
65.50 NP$ (Donate)

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.com V5 Soon!
beaver6813 is offline  
Old 08-27-2008, 04:13 PM   #6 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

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, 04:28 PM   #7 (permalink)
Senior Member
 
nasaboy007's Avatar
 
Join Date: Jul 2005
Location: NJ
Posts: 1,112
1,454.30 NP$ (Donate)

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 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, 04:29 PM   #8 (permalink)
NamePros Regular
 
beaver6813's Avatar
 
Join Date: May 2005
Location: England
Posts: 349
65.50 NP$ (Donate)

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 :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!
beaver6813 is offline  
Old 08-27-2008, 04:31 PM   #9 (permalink)
NPQ's PA, Slave, and On Call Coder

Technical Services


 
Eric's Avatar
 
Join Date: Mar 2005
Posts: 4,545
0.71 NP$ (Donate)

Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute

Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse
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, 04:43 PM   #10 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

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
Quote:
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, 04:59 PM   #11 (permalink)
NamePros Regular
 
beaver6813's Avatar
 
Join Date: May 2005
Location: England
Posts: 349
65.50 NP$ (Donate)

beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough


Quote:
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
__________________
-Beaver6813.com V5 Soon!

Last edited by beaver6813; 08-27-2008 at 05:37 PM.
beaver6813 is offline  
Closed Thread


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 04:47 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85