About Us

News

RSS
A Better PHP Upload Progress Bar Using jQuery
Hopefully, this example of a PHP file upload progress bar will be helpful to PHP  developers who are looking for a simple way to display a file upload progress bar into their online forms and web applications.   This particular method uses jQuery to make the repeating calls to the server to check the status of the upload.

View the demo



Go Back...

Webmaster wrote on 2/10/10 at 7:36am...
"I integrated a new (better) PHP Upload Progress Bar Script in my PHP project.
But script shows %Nan instead of actual percentage. I have installed all server settings properly.

Please help me, how to fix this problem?

Thanks in advance."
Curtis wrote on 3/06/10 at 8:42am...
"I would like to use your script for my multi file upload but I am not able to install apc though I do have php cache and php cache lite, will those work?"
Lee wrote on 3/11/10 at 6:33pm...
"Hi! I have the same problem as Webmaster, it displays NAN% and not the %.. :( How can I fix this??"
Maxime wrote on 4/09/10 at 3:11am...
"Hi, as Webmaster, I also have the same problem... A solution would be welcomed !"
shamubro wrote on 4/18/10 at 12:18am...
"thanks for the great script.

but there is a "bug" in upload_frame.php

$.get("?progress_key=&randval="+ Math.random(), {

change it to

$.get("?progress_key=&randval="+ Math.random(), {


this makes the upload process stays 0 due to the register_globals = off
"
shamubro wrote on 4/18/10 at 12:18am...
"$up_id to $_GET['up_id'] in line 47"
Lee wrote on 4/30/10 at 9:48am...
"whats going on in this block of code...can you add comments please

var refreshId = setInterval(function()
{
$.get("?progress_key=&randval="+ Math.random(), {
//
},
function(data)
{
$('#progress_container').fadeIn(100);
$('#progress_bar').width(data +"%");
$('#progress_completed').html(parseInt(data) +"%");
}
)},500);


i see that its in a JQuery body

1. what value is being pasted to data?

2. what is var refreshId variable doing?

3.where is the value coming from being feed into the #progress_bar width?

4. How is the setInterval function controling the progress bar?"
John wrote on 5/03/10 at 11:43am...
"Lee - check the new files for updated comments.

Thanks,

John"
Lee wrote on 5/04/10 at 2:57am...
"How do i install the uploadprogress PHP extension on windows
i get this error message

PHP Startup: Unable to load dynamic libary 'C:\Program Files\xampp\php\ext\uploadprogress.so'-The specified module could not be found.
when i start XAMPP Apache server

can you email me a copy of the uploadprogress.so file...because i can't get your scripts running local without it.

http://pecl.php.net/package/uploadprogress"
Blade wrote on 5/08/10 at 12:49pm...
"Still have problems with the NaN% issue, I downloaded the latest files and nothing...

how do I solve it???

thanks in advance..."
Lemo wrote on 5/14/10 at 2:27pm...
"I managed to solve the NaN% issues by changing this line of code:

$('#progress_bar').width(data +"%");

to

$('#progress_bar').width(data || 0 +"%");

The || 0 (double pipe and zero) returns 0% when the value being calculated is NaN (not a number)

Hope it works for you also.

Lemo"
Kirk wrote on 6/08/10 at 9:12am...
"I have the upload working, but the progress bar remains at 0% with no animation - Using Gentoo Linux with Apache2/PHP5.2.10 APC 3.0.19 (enabled on phpinfo). I am also unsure about the 'yui' folder, do I need this in the web directory?"
Drumaboy wrote on 6/08/10 at 3:56pm...
"this is all I get please help:

I've installed ACP per your instructions


Warning: move_uploaded_file(tmp/Cost Comparison MI - Retail cost Oct 2009.pdf) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/cdintl5/public_html/test/upload.php on line 18

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpCU3eFb' to 'tmp/Cost Comparison MI - Retail cost Oct 2009.pdf' in /home/cdintl5/public_html/test/upload.php on line 18

Warning: Cannot modify header information - headers already sent by (output started at /home/cdintl5/public_html/test/upload.php:6) in /home/cdintl5/public_html/test/upload.php on line 23"
John wrote on 6/17/10 at 8:32am...
"Drumaboy - The error you're receiving means that your tmp/ directory doesn't exist and you need to first create this directory - or another directory (example: files/, uploads/, etc..) and change it in the upload.php code.

Thanks,

John"
Oliver wrote on 6/18/10 at 1:42pm...
"First I want to say great job with this script. Once you get everything configured, it works very nicely.

My problem is that I switched from a server running Apache2 to one running CGI. Although it could be caused by something else, I think that I am receiving the NaN% error because of this switch, and I was wondering if there is anyway to get around it. I'd really like to use this script since it is the easiest to implement. Thanks againf or all your help."
Bianca wrote on 7/09/10 at 2:50am...
"I used your files and I have NaN% error
I used yours suggestions from this pages but is the same error
Can you help me?"
Connor wrote on 8/20/10 at 10:31am...
"I installed APC and turned on "apc.rfc1867" as shown by my phpinfo file. When I upload a file, the progress bar starts and finishes in seconds, even with a 5MB mp3 file. Changed directory to one that exists. Running PHP 5.3.3 with APC 3.1.4

What could be the problem?"

 


Leave a comment

Your Email Address


Your Name


Message