View Full Version : File Upload with Progress Bar php/javascript

03-30-2009, 01:26 AM
does anyone know a good file upload with progress bar, I've tried and tried to implement one with no luck at all, just cant seem to get it to work

any advice would be most helpful, many thanks

Old Pedant
03-30-2009, 04:09 AM
Would appreciate it if you wouldn't send private messages to many people until you've waited a reasonable time for an answer in the forums. No, 2 hours is not a "reasonable time". Depending on how active the forum is, maybe 12 hours to 2 days.

Anyway, same answer I gave you privately:


I can't see why it would be that hard, depending on what backend technology you are using.

You'd need to be using a backend such as ASP or JSP that allows "session state". You would make *TWO* AJAX requests on the server. First, you'd initiate the data request. Then you'd make a request for the progress percentage. Two different "pages" that share the same session. The one fetching the data would need to store its progress in a session variable. The one getting the progress value would simply read that session variable and return the number to its caller. That caller would update the display and then (perhaps after waiting 1 to 5 seconds, depending on the expected data fetch time?) ask again for the progress.

If the two "pages" can't share session info, then they could share the info via a simple database table. The client could pass a guid, say, to both of them and the data grabber would store a record with that guid as the key value and the percentage progress as the data. Really the same thing as sharing the session, just done ad hoc instead of via the builtin mechanisms.

Never done this, but can't see that it would be that hard.

03-30-2009, 10:32 AM
Thankyu so much for your help Old Pedant, but it simply doesn't mean anything to me
I wouldn't know how to code such a thing
when I follow a tutorial it works on their site but not locally on mine once I've followed their instructions, I'm just trying it without knowing what I'm doing at all with this
anyone feel like leading me by the hand? or know a good tutorial?
sorry to ask

Old Pedant
03-30-2009, 10:51 PM
Ahh, see, that's an entirely different question!

You said "I've tried and tried to implement one with no luck..." So I assumed you meant that YOU were doing the coding!

What you seem to be looking for, really, is a precanned solution, no?

And no, that I don't have. I do know that a company named Persits has done almost exactly what I described for the last 6 to 8 years, long before AJAX came into being. They do it using an <IFRAME>. They use a META REFRESH in the <IFRAME> to keep loading in a new progress image. But, as I said, it only works because both the page displayed in the <IFRAME> and the page that is doing the work (in their case, it's for a file upload control) are able to share "session" information. It happens to be written in ASP code, but I know the same concept would work fine with JSP. I don't use PHP, so I dunno if PHP supports "session variables" in the same way, but if it does then you could use the same technique.

I really do think that an experienced PHP and JavaScript developer could throw this together in a couple of hours (again, assuming that PHP supports session varaibles the same way...add a few more hours if the session trick wouldn't work), but with no experience in PHP, that person isn't me. I could do it in ASP or JSP, though. Maybe not the prettiest version, but it would work, I think.