PHP Upload Progress Bar

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

PHP Upload Progress Bar

Post by Grim... »

User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Didn't seem to do anything for me when I tried the demo.

It opened a popup, hung for a while, then threw a window that said upload complete :?

Again, I reckon you can do this with AJAX.

Send the file, have ajax, every 1 or 2 seconds, query the server for the file size of the upload so far, compare it against the full file size sent from the file field and do your calculations :)

Two nested divs always work well to make little progress bars.
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

d11wtq wrote:Send the file, have ajax, every 1 or 2 seconds, query the server for the file size of the upload so far, compare it against the full file size sent from the file field and do your calculations :)
Where would you get the size of the original file from without going through the user's hard drive?

<edit>It worked fine for me. Did you give it a file > 1mb?</edit>
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Grim... wrote:
d11wtq wrote:Send the file, have ajax, every 1 or 2 seconds, query the server for the file size of the upload so far, compare it against the full file size sent from the file field and do your calculations :)
Where would you get the size of the original file from without going through the user's hard drive?
You could combine the ideas from this upload thing with an ajax system .. still use the pop up window, just have it use Ajax to get the info rather than a meta refresh.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

worked for me in IE7
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Grim... wrote:Did you give it a file > 1mb?
Hmmm.. yeah it was a PDF that was 1.4MB. Usinf Firefox 1.0.5 in Linux.

I'll give it another shot.

You'd retreive the original filesize by reading the values from $_FILES['field_name'][] although I'm not sure they'd appear midway through the upload. The client sends the data as far as I'm aware.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

perdy slick
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

Worked for me in FireFox 1.0.7.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Shhwwweeeeeeeet! Just tried it in 1.0.6 from home. Works a treat. I still reckon that's how it's done, only using a meta-refresh.

I'll have a stab using AJAX, and better DHTML so I can animate the bar sliding ;)
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

that would be ultra slick if it was real time instead of the meta refresh.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

shiznatix wrote:that would be ultra slick if it was real time instead of the meta refresh.
Guess what d11wtq is doing right now :P
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

Bashing da bishop?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Grim... wrote:Bashing da bishop?
:oops: How did you know?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I failed, on first attempt :(

Was trying to use ajax to do it from a single file but of course as soon as you hit the submit button it wait until the data is sent :roll:

EDIT | Ohhhhhh 8) It's coming to life now :D

EDIT again | Gives up :(
Last edited by Chris Corbyn on Wed Nov 02, 2005 2:53 pm, edited 1 time in total.
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

this is gonna be sweet. hurry! :D
Post Reply