Upload Progress Bar

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
rajsekar2u
Forum Commoner
Posts: 71
Joined: Thu Nov 20, 2008 4:23 am

Upload Progress Bar

Post 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
User avatar
jazz090
Forum Contributor
Posts: 176
Joined: Sun Apr 12, 2009 3:29 pm
Location: England

Re: Upload Progress Bar

Post by jazz090 »

php is server side which means everything stops untill the file is uploaded therefore there is no way to detect the progress
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: Upload Progress Bar

Post 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.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Upload Progress Bar

Post by Darhazer »

You can use ACP to do this (PHP 5.2+)
Tracking file upload progress
User avatar
jazz090
Forum Contributor
Posts: 176
Joined: Sun Apr 12, 2009 3:29 pm
Location: England

Re: Upload Progress Bar

Post by jazz090 »

ahhh nice, i had no idea this could be done
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Upload Progress Bar

Post 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
Post Reply