Blog Posts

Upload Progress Meter extension 0.9.2 released

Today, I released uploadprogress 0.9.2, nothing groundbreaking since the initial 0.3 release, mainly bugfixes (changelog). This means that there are still no other SAPIs than mod_php officially supported.

The main new function since 0.9.1 is uploadprogress_get_contents($id), which allows you to analyse the content of an uploading file during the upload and do appropriate measure (for example warn the user, that he doesn't upload a supported video format). You have to enable this feature in php.ini to make it work. This feature was provided by Ben Ramsey, so you have to poke him, if something's wrong with it.

Another major addition is an as-simple-as-possible example, which also tries to give meaningful error-messages, for example if your file-to-be-uploaded was way too small to say for sure if it worked or not. It also doesn't use any fancy AJAX/XHR/Technology-of-the-day Shizniz, just plain old iframes with some reloading Javascript code and three PHP files. See http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/examples/ for the code, put them into a directory of your webserver and it should work (or as said give meaningful error messages). You can also see it in action in our labs at labs.liip.ch/uploadprogresssimple.

As an alternative to the uploadprogress extension I can also recommend the YUI Uploader component, which uses Flash and therefore doesn't need any server side components for doing a progress bar. It also has additional features like multiple file selection. But a Flash based solution may or may not be ok for you :)

In a next post I'll write about some of the common pitfalls and problems one may encounter with this extensions. I hope that will clarify some of the more common issues.

Related Entries:
- Upload Progress Meter 1.0.1 released
- Upload Progress Meter - Common issues and some answers
- Upload Progress Meter for Windows - The next take
- Upload Progress Meter for Windows
- Upload Progress Meter finally in PECL

About the author

Comments [31]

Micke, 22.01.2009 16:30 CEST

Hello!

I use the 0.9.2 version and the only thing uploadprogress_get_info() returns is NULL..

I use:
Apache/2.2.9 (Debian) PHP/5.2.6-0.1~lenny1 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g

Do you think there can be a suhosin problem like there is with apc_fetch()?


//Micke

Chregu, 22.01.2009 16:56 CEST

Yes, you have to use one of the later Suhosin releases (at least 0.9.26). There was a problem with the releases before and uploadprogress doesn't work with them.

Simon, 22.01.2009 18:36 CEST

If there is a heaven, it is reserved excusively for those who don't use Ajax.

Sincere thanks :)

Micke, 22.01.2009 19:08 CEST

Hi there again...

I'm using Suhosin Patch 0.9.6.2.

Alex, 22.01.2009 20:03 CEST

I cannot get clue where the function "uploadprogress_get_info" is located. Maybe I've lost any file?
index.php
info.php
server.php

Thank you!

Chregu, 22.01.2009 20:34 CEST

Alex, 23.01.2009 11:11 CEST

Yes, now the line is there and I still get an error, sorry for bothering but do I need to include the source code of the function from somewhere?

Fatal error: Call to undefined function uploadprogress_get_info() in T:homevirtualprimeinfo.php on line 19

Thank you

Chregu, 23.01.2009 11:45 CEST

Alex: You don't have the uploadprogress extension installed (or not restarted your webserver after installation)

Without the extension, it doesn't work

sunfish, 25.01.2009 11:11 CEST

Thank you for this nice extension.
I tried to upload a file bigger than 20M on your example page. The upload started with no information about the upload status and in the end an error message was shown:
"PHP did not report any uploaded file, maybe it was too large, try a smaller one (post_max_size: 20M)"

Is it possible to stop the upload, if the file is too large?
And is there any possibility to resume a broken upload?

Chregu, 25.01.2009 11:56 CEST

Sunfish: That particular problem will be part of my next post, but in short: No, it's not possible to detect uploads larger than post_max_size, due to API limitations in PHP. You can detect if a file is larger than upload_max_filesize, but an abort is also only possible on the client side, reloading the page for example

seb, 28.01.2009 19:59 CEST

Hello,

I installed the pecl extention and restarted httpd... but still get the Call to undefined function uploadprogress_get_info() error.

I have fulle root access and php 5.2 and appache 2.2 installed...

any clue? thanx in advance..

Chregu, 28.01.2009 21:39 CEST

Some things you could check:
Does thr extenions show up in phpinfo()?
Did you add it in php.ini?
Is uploadprogress.so in the correct directory?

Alex, 29.01.2009 15:08 CEST

Hello! Please, advise where I can download uploadprogress extension. Cause I've tried to compile it with VS6 but unsuccessfully :(

Thank you

sertar, 01.02.2009 22:35 CEST

Hello,
I am trying to use your extension uploadprogress but i have some troubles having it work.
I installed it by doing :
pecl install channel://pecl.php.net/uploadprogress-0.9.2
and then add the extension to php.ini. restart apache.
phpinfo returns the extension properly.
When i try to use the function it always returns NULL.
I also tried apc, it works, but i would prefer uploadprogress can you help me please?
Sertar

Ps: Apache/2.2.9 (Debian) PHP Version 5.2.0-8+etch13

Vivek Puri, 02.02.2009 06:11 CEST

Christian,

As it seems, uploadprogress_get_contents requires 2 params, instead of 1 as you indicated above. The v 0.9.0 changelog says - uploadprogress_get_contents(id, fieldname). So what would be the fieldname in this case?

Also i had another question. If the user uploads a file larger than what is permitted in the ini settings, is there any way to stop the file upload?

Vivek Puri, 02.02.2009 06:46 CEST

Okay, trying to answer my second question above - If the size of the file being uploaded is really more than the ini settings, we can set the document.getElementById("ifr2").src = '' and the upload stops. Is this a good approach?

Chregu, 02.02.2009 08:14 CEST

Vivek: Fieldname would be the name of your field for the file upload (since you can have more than one upload field, that ist needed)

your solution for stopping an upload is a possible way, I don't know of any completely different approaches. You can't catch an upload which is larger than your maximal POST size. Will be in my next blogpost, which I still have to write :)

Sertar, 02.02.2009 14:25 CEST

I've been searching a lot on the web, still don't get the solution. It seems that some people have the same problem but no answers. What should i do? newer php version? older extensions, compile it entirely without pear?

Thank you very much
Sertar

PS: more info in my previews post.

Chregu, 02.02.2009 14:28 CEST

Sertar: I don't know. It's hard to debug this way. Works for me with Apache and mod_php

Sertar, 03.02.2009 14:32 CEST

Okay chregu i have found my probleme which is very stupid :
In my php.ini i used to seperate the pecl extensions of the other php mods, but i don't know why i have put it all the way down in the file. I 've moved it back to the others extensions place and it works perfectly! Thanks.
When is the stable coming?
With the memcached system?

Sertar

Vivek Puri, 03.02.2009 14:57 CEST

Christian,
Can you please provide more details on what issues we might come across if memcached is also used on the server?

Chregu, 03.02.2009 15:12 CEST

Sertar: It's stable enough already, I think I just release it as stable soon, so I don't have to answer that question anymore :)

A memcached based system isn't coming in the foreseeable future, at least not written by me.

Vivek: There are no known issue with memcached. This extension doesn't use memcached at all

Mike Smith, 11.02.2009 00:00 CEST

I got the extenstion installed, but the example says "BUT there were no progress meter updates
Your upload should have taken long enough to have an progress update. Maybe it really does not work..." after the upload, and never gets the progress

So What does this mean? Any thoughts?
Its showing up properly in my php info, but it always remains null as it is uploading.
What am I missing here?

Jason, 22.02.2009 02:43 CEST

I am receiving the same NULL result as posted above from others. A file is uploaded just like a normal form and no info is ever displayed in the iFrame. I have the extension installed and it is shown in phpinfo(), and the functions also work... just not why it's not updating.

Chregu, 22.02.2009 08:51 CEST

Jason : Can you use the example from here http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/examples/

You used an old one, but even that basically worked for me, I got something back which was not just NULL

Jason, 22.02.2009 09:07 CEST

Chregu: That is the example I am trying to use. It works on another server I am working on, just not mine. I tried disabling the Suhosin extension, but it made no difference. But as it works on the other server, I know it's not a wrong move I made on installation. It must be conflicting with something else...

Kober, 15.08.2009 03:32 CEST

So how do you stop the uploadprogress from continuing in the background even after I press stop on the browser? The progressbar stops updating on the page when I do this and appears to stop but if I look at my connection there are still packets being sent. How do I kill the script when a user aborts it?

Chregu, 17.08.2009 08:32 CEST

Kober: You have to take care of that in your javascript methods. The getinfo call shouldn't return anything anymore, so you can stop the program (or not let it check the upload status). It's not the extension doing that, but the javascript part.

Ryan, 09.02.2011 09:07 CEST

Hi, I'm trying to use the uploadprogress extension but not able to get it working. I am running on a Windows machine with Apache 2.2.11 and PHP 5.3.5.

I have added the php_uploadprogress.dll to my ext directory and included the extension in the ini file but when looking at phpinfo, I do not get anything that gives any indication of uploadprogress having loaded. This leads me to the next requirement that we are using mod_php, now I cannot for the life of me figure out how I can confirm this. I did a standard Apache install, how do I know if I am using mod_php? In phpinfo I can see a mod_php5 loaded, is that proof? (I can also see mod_cgi, not sure if that is what determines CGI use...).
I have scanned numerous pages on the web to find out how I know which method I've used but absolutely nothing is definitive, I truly hope you can help!

Thanks
Ryan

Ryan, 09.02.2011 11:48 CEST

Scrap my last post, have it working now. Problem was I had the file for PHP v5.2 but thankfully found the v5.3 file on another link

Kobers, 29.03.2011 10:59 CEST

Thanks Chregu, great extension. I see it is now in use on a phpBB3 mod called 'Real Upload Progress bar' and works quite well ;)

Add a comment

Your email adress will never be published. Comment spam will be deleted!