Page 1 of 1

Upload Progress Bar

Posted: Wed Jun 03, 2009 8:04 am
by rajsekar2u
Hi all,

Hi have created a script for file upload upto 10mb.

I need to show progress bar for it using ajax.

Please give me some idea or an example script

Re: Upload Progress Bar

Posted: Wed Jun 03, 2009 9:30 am
by jazz090
php is server side which means everything stops untill the file is uploaded therefore there is no way to detect the progress

Re: Upload Progress Bar

Posted: Wed Jun 03, 2009 10:22 am
by mikemike
He asked about AJAX though. There are some scripts available out there that do this. A simple Google search brings up plenty of results that match your needs.

Re: Upload Progress Bar

Posted: Wed Jun 03, 2009 2:06 pm
by Darhazer
You can use ACP to do this (PHP 5.2+)
Tracking file upload progress

Re: Upload Progress Bar

Posted: Wed Jun 03, 2009 3:47 pm
by jazz090
ahhh nice, i had no idea this could be done

Re: Upload Progress Bar

Posted: Thu Jun 04, 2009 4:03 pm
by Darhazer
jazz090 wrote:ahhh nice, i had no idea this could be done
Actually there was a couple of ways to do this before PHP 5.2
The problem is not in server side, the problem is that PHP gives control to your script after the file is uploaded (which I think is done to simplify the file processing, directly using the $_FILES variable)
And you can always call another script, using AJAX, to tell you the progress, because you are not uploading a file to it, hence it is called before the file upload ended. But it have no idea what file is the one being uploaded. Here comes the ACP. Before it, you can either use Perl script to process the upload, or use a third party PHP extension, which is not suitable for shared hosting :mrgreen:

And by the way, keep in mind:
There are no impossible dreams