Upload progress

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
EricS
Forum Contributor
Posts: 183
Joined: Thu Jul 11, 2002 12:02 am
Location: Atlanta, Ga

Upload progress

Post by EricS »

Is there any way to get the status of a file that is being uploaded through the file uploaded field of a form?

It appears to me that the PHP parser doesn't even start working till all the data from a form has been completely uploaded from a form.

Maybe this is something better done with Javascript.
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

The only way if i am not mistaken.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

The only thing you could do is to pop up a new window with javascript when you submit the form - this will then show a window saying "please wait" or something, and then when the file has been uploaded you can have the first window close this pop-up.
rapaddict_dot_com
Forum Commoner
Posts: 27
Joined: Tue Mar 16, 2004 4:54 pm

Post by rapaddict_dot_com »

wats the code for this? and can it show how much % of the file is uploaded?
EricS
Forum Contributor
Posts: 183
Joined: Thu Jul 11, 2002 12:02 am
Location: Atlanta, Ga

What I've found so far.

Post by EricS »

From what I understand, php scripts can't access raw post data as it's being uploaded. Only after the data is uploaded and pre-parsed by php can you access it.

Now this pretty must makes an upload progress bar through PHP alone impossible, because it's to late to run a progress bar AFTER the file is already loaded.

This brings me to Javascript. From what I understand, Javascript does not have the capabilities of asking the browser how far along it's upload is either. So this rules out using Javascript for an accurate progressive upload bar. Now, if I'm not mistake, Javascript can access the file size of files chosen in a file upload file, at least in IE. So you can choose an average upload speed and make a predetermined guess as to how long it will take. But this will only be a guess.

While I do not know this for certain, I've heard that PERL does have the capability of accessing raw posted data as it's uploaded. Using a combination of PERL and javascript and PHP, some one has written a package that could do an accurate progressive uploading bar.

Here's the URL http://www.raditha.com/php/progress.php
Post Reply