Upload Progress Meter extension for PHP 5.2

Showing a real progress bar when uploading large files is an often requested (and quite informative) feature, which is not easily doable with the way the upload handling works in PHP.

There is a patch available for PHP 4.4 and 5.0, which made it nevertheless possible, but some php core files itself needed to be patched for that.

But approx. 2 months ago a similar patch was committed to the PHP_5_2 branch which now makes the patching of PHP unnecessary. You still need an extension for getting the data and that’s what I wrote last weekend. It’s based on the work of Doru Petrescu, but as the patch is quite different, I started from scratch, but copied some helper functions and the basic idea from Doru’s extension.

Here’s the code and svnweb.

As this new uploadprogress extension is almost compatible with the one from Doru, you can use his demo files or the ones by Joshua Eichorn described on his blog using the html_AJAX UploadProgressMeter. Just rename the function upload_progress_meter_get_info() to uploadprogress_get_info() in all the files. The source code is here.

If there’s enough interest in the extension, I may try to submit it to PECL. I will also try to add a memcached based mode instead of writing to files.

And as always, use it at your own risk, I didn’t test it very thoroughly (especially not at all on windows :) )

Update: It’s now finally in PECL: http://pecl.php.net/package/uploadprogress. The latest sources are also available there

Update 2009: If you have problems get it running, see the “common Issues and some answers” blog post and check the new example, which comes with the extension and is also available here.


Thanks for the work :-)


Great work Cristian, looking forward to 5.2 going stable so I can put this to work.

Nice work ! Having on the PECL would be great :)


Very cool.

What’s the role of the filename template BTW: uploadprogress.file.filename_template ? How does the ID you pass into uploadprogress_get_info() from userspace get matched with what the php_rfc1867_callback is reporting as incoming files?

I guess related – annoying edge case question: how do you cope when two files of the same name are being uploaded roughly the same time by _different_ people?

Great! Unfortunately I also have to wait until PHP 5.2 goes stable. Anyway you should definitely try to submit it to PECL.

Submission to PECL would be great! Thanx for the work! :-)

This looks like it will be very useful to the community. Thanks for the hard work to both you and Doru Petrescu.

Hi Christian: Great work! Would it also be possible to upload the Windows version of this extension to PECL4WIN? Thanks very much!

Carlos: I don’t have a windows developement environment :)

Harry: You have to provide a unique ID as (hidden) input field with the name UPLOAD_IDENTIFIER (and it has to be before the file fields)

How you generate that ID is up to you. But if 2 people get the same ID, then the output will be quite chaotic…

A PECL extension would be really great. thank you very much for contributing.


waiting for that feature for years now! yes – plase put it into PECL. thank you!

the compiler can’t find this function multipart_event_start in rfc1867
i use php-devel.x86_64 version 5.1.4-1

Rachid: You need PHP 5.2 for this extension

under linux is working tanks chregu

i try to install it under windows but i got this message
( Cannot open include file: ‘php.h’ )

Definitely put it in PECL!

I got php 5.2 compiled it for my box, but the example script I pulled down could generates an error:

Call to undefined function apc_fetch().

is there something other than the 5.2 dev I should be getting from snaps.php.net?


Sounds like you need the Alternative PHP Cache: http://pecl.php.net/apc

You can get this package through the PECL/PEAR installer as well.

BTW, PHP 5.2.0 is out now. See http://www.php.net

PHP 5.2 is official
one of the changelog is

Added RFC1867 fileupload processing hook. (Stefan E.)

We hope upm ext will be in official src
or be submited to pecl

thank you!

To all guys waiting for the pecl release:

I currently don’t have the time to prepare it, so if anyone can help me out, that will happen sooner than later. The sources are here:


What’s basically missing is a proper package.xml and some testing that the installer really works

And another task would be to try to compile it on windows :)

I wanna get some help from u
I use lighttpd 1.4.13 + fastcgi php 5.2 and upm ext
and UploadProgressMeter mentioned above

but I got a server 503 error while uploading use

the lighttpd log is
2006-11-03 15:58:30: (log.c.135) server stopped
2006-11-03 15:58:31: (log.c.75) server started
2006-11-03 15:58:38: (mod_fastcgi.c.2396) unexpected end-of-file (perhaps the fastcgi process died): pid: 398 socket: unix:/tmp/php-fastcgi.socket-0
2006-11-03 15:58:38: (mod_fastcgi.c.3181) response not received, request sent: 20849 on socket: unix:/tmp/php-fastcgi.socket-0 for /u/demo.php , closing connection
2006-11-03 16:02:55: (mod_fastcgi.c.2930) write failed: Broken pipe 32

can anyone help me?

and the up ext version is:
0.1-alpha $Rev: 8198 $

revision 8191 works

it seems that 8198 breaks the upload progress

anyone who wan’t to enjoy the amazing thing can svn co -r 8191

please chregu check it
thanks to your hard work

I have some trouble with complining the windows DLL.
VS 6 wants the php.h file which he did not recognice. I got it from PHP 5.2 Source and added it to the project but still gettin the same error :(
>>Include-Datei kann nicht geoeffnet werden: ‘php.h’: >>No such file or directory

Its a long time ago where i worked with VS 6 so if anyone can help me or has compiled the windows.dll …

thank you

I have to report a bug
I don’t know if it’s lighttpd’s or the mod’s

I’ve tracked the upload progress.
It seems that in lighttpd fastcgi php environment,
lighttpd handles the upload file,
then transfer the file to php
so php’s rfc1867 function invokes the callback
(which is uploadprogress_php_rfc1867_file callback in this module)
in a very very short time.
so the status jumps from “Connecting…” to “Upload Complete”

and I have some question on these lines of codes

88 *e_data->newlength = e_data->length;
maybe it should be e_data->newlength = &e_data->length;

161 if (dt || event >= MULTIPART_EVENT_FILE_END) {



tested it also with PHP 5.2.
The newest revision breaks when a file is uploaded (segment fault), but with the revision before that it works only a bit.
So there is now real upload progress. The Status bar jumps from “Connection” to “Upload Complete” :-/
Using Apache2.

Greatings from Germany

There’s a known problem (the segfault) which I couldn’t fix until now, ’cause I didn’t have the time to look into it closer. I reverted that change for now, so it should at least work for some people (while for others it still doesn’t)

So don’t bother too much for the time being until I found the culprit


anyway nice work you are doin here.
I testet it again and with the PHP-Source from pdoro (the first one) the extension worked a bit more ..
First in only saw the “Connecton” and “Upload completed” messages, with the source from upload-progress-bar-4.1 i could see a process in the uploading, only at the end it fails (the status bar only reloads but doesnt go on), so I inserted some session variables in my code and now its works.


I commited some fixes here and there and it should work better now

Please try it out

that demo is very cool.

I compiled revision 8230 and activated it successfully using Mac OS X 10.4.8 and Apache 1.3, but the function uploadprogress_get_info() always returns NULL. Did anyone manage to get the extension to work on OS X?

The demo on this site does not really work. The progress bar just jumps to Upload complete instantly but the progress is far from complete. Just tru uploading 5MB file and see.

Something is not quire right.

I looked inside the /tmp directory while uploading the file and I saw this file: /tmp/upt_%s.txt

I also saw that contents of this file changing as upload continues, which is good, so it means it’s working, but I think the % should be replaced by some sort on usique ID and for some reason it’s not being replaced.
I think that’s why the extension is not displaying the progress properly.

Please look into this and hopefull you can fix it soon. This is the only reason I’m not upgrading to php 5.2.0 and still using 5.1.6 with a upload_progress_meter patch and an old upload_progress extension.

Dmitri. It works for me with the /tmp/ file directory. No Idea why it doesn’t for you

I was using it with HTML_AJAX uploadprogressmeter. I changed the function name in one place in UploadProgressMeter class.

I will try to download your demo version and see if it works, maybe I missed something.

I am too developing a CMS in php, focusing on image hosting, but also a blog engine. I have a working version of uploadprogress with patched php5.16 right now.

it’s on http://www.sharedlog.com

Hope to be able to upgrade to php 5.2.0 as soon as I figure out how to make upload progress work with this new extension.

I’ve modified this module to also support mysql for it’s information storage. Who should I send a patch/code to?

I can install this nifty extension on redhat es4, but make chokes on my debian woody box with:

/usr/local/src/php-5.2.0/ext/uploadprogress/uploadprogress.c: In function uploadprogress_php_rfc1867_file':
/usr/local/src/php-5.2.0/ext/uploadprogress/uploadprogress.c:142: parse error before
/usr/local/src/php-5.2.0/ext/uploadprogress/uploadprogress.c:145: crtime' undeclared (first use in this function)
/usr/local/src/php-5.2.0/ext/uploadprogress/uploadprogress.c:145: (Each undeclared identifier is reported only once
/usr/local/src/php-5.2.0/ext/uploadprogress/uploadprogress.c:145: for each function it appears in.)
dt’ undeclared (first use in this function)
/usr/local/src/php-5.2.0/ext/uploadprogress/uploadprogress.c:150: ds' undeclared (first use in this function)
d’ undeclared (first use in this function)
/usr/local/src/php-5.2.0/ext/uploadprogress/uploadprogress.c: In function uploadprogress_file_php_get_info':
/usr/local/src/php-5.2.0/ext/uploadprogress/uploadprogress.c:310: parse error before
/usr/local/src/php-5.2.0/ext/uploadprogress/uploadprogress.c:313: `template’ undeclared (first use in this function)
make: *** [uploadprogress.lo] Error 1

Can anybody compile that source code?
That would be useful, Please don’t be so polarized. Linux is not the end of the world. I need windows .dll file – thanks

This extension causes a problem with the Suhosin patch. Which probably means it’s doing something it shouldn’t be doing.

Error message in apache log:
ALERT – canary mismatch on efree() – heap overflow detected

(after which the script is aborted).

Any ideas?

I found the problem that causes Suhosin to freak out. When you submit a form that has enctype=”multipart/form-data”, but has no files to upload, the error I described above occurs.

I think this is a bug that could be pretty easily fixed, but I don’t know enough about the zend extension API to do this.

Jeremy: Did you use the latest version from Subversion? (just to make sure…)

Hmm. I’m trying to compile it on windows and I get:
c:php-5.2.0extuploadprogressuploadprogress.c(142) : error C2275: ‘time_t’ : illegal use of this type as an expression
c:program filesmicrosoft visual studiovc98includesystypes.h(28) : see declaration of ‘time_t’
c:php-5.2.0extuploadprogressuploadprogress.c(142) : error C2146: syntax error : missing ‘;’ before identifier ‘crtime’
c:php-5.2.0extuploadprogressuploadprogress.c(142) : error C2065: ‘crtime’ : undeclared identifier
c:php-5.2.0extuploadprogressuploadprogress.c(143) : error C2143: syntax error : missing ‘;’ before ‘type’
c:php-5.2.0extuploadprogressuploadprogress.c(149) : error C2065: ‘dt’ : undeclared identifier
c:php-5.2.0extuploadprogressuploadprogress.c(150) : error C2065: ‘ds’ : undeclared identifier
c:php-5.2.0extuploadprogressuploadprogress.c(151) : error C2065: ‘d’ : undeclared identifier
c:php-5.2.0extuploadprogressuploadprogress.c(280) : warning C4098: ‘zif_uploadprogress_get_info’ : ‘void’ function returning a value
Error executing cl.exe.

php_uploadprogress.dll – 7 error(s), 1 warning(s)

Any ideas – anyone?

Jeremy: The remote exec problem should be fixed in my SVN , if it still doesn’t work, just tell me …

Kelvin: No idea about windows, maybe someone else…


I am running into the same issue, but i believe this particular issue is due to the build code is designed for PHP 4.x – not PHP 5.

I fixed your particular issue by taking the definitions occuring on lines 142 and 143 and putting them at the beginning of the function:

time_t crtime;
int d,dt,ds;

and leaving the actual call behind on 142:

crtime = time(NULL);

and in my case, defining _USE_32BIT_TIME_T in the header (using VC++ 2005 Express).

But i cant get any further with all of the linking refering to a PHP 4.x enviornment.

1>Compiling manifest to resources…
1>LINK : fatal error LNK1104: cannot open file ‘php4ts_debug.lib’

With my limited experience, i cant fix this completely. Any assistance from someone trying this with windows would be a huge help.


I’m surprised that you fixed the compile problems as the problems with linking are relatively simple.

In Visual C++ 2005, open your Project and go to the Project Properities (under the Project menu – or simply press Alt-F7). In the tree of options on the left, go to Configuration Properties, then Linker, then Input and finally look at the Additional Dependencies box on the right. You can change the name of the lib to whatever you need it to be
(e.g., php5ts_debug.lib). Note: You may have to change the path to the library under the General options.

I don’t know if this needs to be said, but you need to have the phpts5_debug.lib prior to attempting to compile the uploadprogress extension. That means you have compile PHP first (doh!). I find it easier to build Release builds rather than Debug builds since the Release lib comes with PHP distribution (in the dev directory).

Hope this helps.

Thanks for the info!! Thats what i was hoping, that this would be a simple fix at this point. Once (and if) i can get a good compile and get it tested, i will post a link (with Christian’s permission) to a windows DLL and the adjusted source code.

I have the source code already downloaded for PHP – and installing the real Visual C++ 6.0 right now to see if this helps make life easier.

I will keep you informed.

SteveH: Cool, I’m looking forward to the patches (the automatic build of Windows dlls can then be taken care of by http://pecl4win.php.net/ :) )

If all you need is the patch to make it compile, its a really simple adjustment. (i would send the file, but running on windows, there could be all sorts of issues, so i am just going to describe the fix).

Line 142:

time_t crtime = time(NULL);

crtime = time(NULL);

Line 143:

int d,dt,ds;

Line 72:

Insert two lines:
time_t crtime;
int d,dt,ds;

(the compiler is just having a fit with defining the variables within an ‘IF’)

I am still struggling to get a “debug” enviornment built , so the patch is still untested in a DLL form. But it will at least compile now inside of VC++ 6. Any more info on switching to a “release” build would be helpful (i am personally not much of a C++ coder unfortunately).


Switching to a release build is easy. In VC++ 6, go to the build menu, select Set Active Configuration and switch the configuration to “Release.”

Of course, you should make sure all the linked in libraries were also built as Release as well.

Fiddling with compilers is a dark art in itself.


Here is a patch that i made with the PECL CVS. I couldnt get an enviornment to work here, so i hope we can get it running on pecl4win.

Following the advice of some previous posts, here are the changes I made to uploadprogress.c to get it complile on Solaris 8:

Insert at line 72 (right after “int read_bytes”):
time_t crtime;
int d,dt,ds;
Change line 143 from:
time_t crtime = time(NULL);
crtime = time(NULL);
Remove line 144 (“int d,dt,ds;”)
Insert at line 308 (right after “char * filename;”):
char * template;
Change line 311 from:
char * template = INI_STR(“uploadprogress.file.filename_template”);
template = INI_STR(“uploadprogress.file.filename_template”);

Ah, I was using the tar that’s linked to in the post. I’ll try the one from PECL (it seems to have been updated yesterday so it’s probably pretty up-to-date, right?)

Try the latest CVS version (0.3.1-dev), there was a bug that caused that – which has been fixed.

Where do I find the latest CVS version? – thnx

Your extension worked great after I installed php 5.2.0 and changed the function-calls as instructed! Plug-n-play! :)

Thanks for the hard work!

Although – it has stopped working. Today – the uploadprogress php function returns NULL when a file is being uploaded. I can track the progress manually by watching the size of the phpAAAAAA-file in /tmp. I have traced the “error” back to the fact that there no longer is a file called upt_something.txt created in php temporary upload folder (I
didnt verify that it was there when it was working but I have guessed my way to the fact that it probably were since the entension – using the default ini-value of uploadprogress.file.filename_template – relies on this file?)

I am not sure about this, but I think it was around the same time that I on top of the suhosin-patched php also installed the suhosin extension. This is a bit strange if it would be the error since usually suhosin is very good at logging stuff when it prevents something to happen but no output from suhosin is generated…

I am running Apache/2.0.55 (Ubuntu) PHP/5.2.0-0.dotdeb.3 with Suhosin-Patch mod_ssl/2.0.55 OpenSSL/0.9.8a

I just updated your extension from 0.2 to 0.3 – the problem persists.


1. Any frank ideas on what could be the matter here?

2. Could you have the extension throw an error or something similar for examle E_UPLOADPROGRESS_NOPROGRESSFILEFOUND if the file is not found?

Best regards,


Motin: First, can you please test the CVS version, if possible. I made some fixes (but mainly for bugs introduced after 0.3.0), maybe there was something wrong in 0.3.0, too (but I use that version and it works for me)

And for the second request, the function returns NULL, if no file found (or something else is wrong, but usually it’s a file not found). The problem is, that when the upload has finished, the file isn’t htere anymore, and it would return that then, too. Which would be a little bit strange IMHO…

Thanks for anwsering so quickly!

I ask the same as Ryan above: Where do I find the latest CVS version? Should I download the files one by one from https://ssl.bitflux.ch/horde/chora/misc/uploadprogress/ ?

Maybe you should have the command for anonymous checkout in your blogpost.

About the second request – A user should be able to write code that always expects the extension to return something about the upload in progress. In case nothing is found, an easily suppressed notice could be thrown to alert about this.

Motin: The latest CVS sources are here: http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/

A short description, how to download that is here

For the 2nd request: I will not throw a “notice” for expected behaviour. When the upload is finished, the file is gone and returning a notice there is just bad practice IMHO. I can’t differntiate between “no file at all” or “no file because the upload has finished or not started yet”. The upload process itself and the one which calls
uploadprogress_get_info are completely independent of each other and they can’t talk with each other except through that file (and no, I can’t write into that file “upload finished” since it has to be cleaned somewhere and that somewhere has to be in the upload process itself)

If uploadprogress_get_info returns NULL, then there’s no file. There are no other states, therefore that should be enough and you can check for NULL in your code

Would you mind specifying the direct checkout-path to your extension? I am not too kern about checking out the whole php source tree and I am not too familiar with cvs. It seems there is a subversion repository where the extension lies as well? I use subversion daily. Do you have the direct path to the folder in the repo? Tried scn checkout
https://ssl.bitflux.ch/horde/chora/misc/uploadprogress/ without success…

> and no, I can’t write into that file “upload finished”
> since it has to be cleaned somewhere and that
> somewhere has to be in the upload process itself

Why not? It is a great function as soon as the user has chosen the behaviour, for instance through uploadprogress.leave_uptfile_after_finished_upload=1

And then let the extension cleanup upon finding the upload finished. The user will know that he has to cleanup manually if he enables this option for the uploads that were aborted.

“Maybe you should have the command for anonymous checkout in your blogpost.” – I’ve never done this before so after some monkeying around:

cvs -d :pserver:cvsread@cvs.php.net:/repository checkout pecl/uploadprogress

hmm. I just finished upgrading the latest cvs version, and nothing has changed – progress bar still just jumps to finished.

Could I be missing some ./configure options or something like that?

Ryan: Maybe the upload is just too fast :) Or did you try with a large file over a slow connection?

Morton: I won’t change it. Really :) Your proposal brings more problems than it solves for the various reasons I mentioned above (mainly 2 different processes, which both can be aborted or not finished independently. Not even the cleanup has to be called and then you have many stale files laying around).

I’ve tried uploads of various sizes.. and as mentioned. the upload will continue on, and finish at normal time, while the progress bar just jumps to finished right away.

I wrote my own simple upload script, to test to see if it would work. It doesn’t use ajax to display the status, it rather, just reloads an iframe given the upload_identifier, to see if the status function was actually returning anything.. It just returns null…

I am using that example (http://files.bitflux.ch/uploadprogress-example.tgz). I just changed progress.php to show a progress bar instead of the upload array. After the upload is complete the page does not go to upload.php. So I am having problems figuring out where the file is (from PHP). I can see the file with “ls /tmp” while the file is
uploading but once the file is finished it gets errased. If I remove the call to function progressStart() I get no progress bar but the page does update to upload.php (like it should) and the file can be found.

OK nevermind, I understand now upload.php is going to the iframe. I totally missed that.

I installed your PECL extensions (downloaded from http://pecl4win.php.net/list.php/5_2) on WinXP, with PHP5.2. The Phpinfo() said me that it was well installed.
Then, I ‘ve downloaded the demo files from Doru Petrescu and renamed the function upload_progress_meter_get_info() to uploadprogress_get_info(). My problem is that when I try this demo file on my web server, the popup gives me an error message : “Invalid meter ID!”. It seems that uploadprogress_get_info doesn’t return anything. I don’t understand
why … Any idea ?

Other question : Is it possible to set the temporary folder to another path ?

Sorry about these “silly” questions …

The Windows version of the extension is still having difficulties – http://blog.bitflux.ch/archive/2006/12/05/upload-progress-meter-for-windows.html.

However, in your case, it is most likely an issue with the upload completing before the popup window has a chance to request information about the upload.

I am using that same script, and have to turn up my upload allowances to 500mb in order to get a decent amount of time to upload to my local computer.

great work
where can we found some proper documentation about how is this extension supposed to work.

It works (at least on debian)! Great stuff! Thx a lot.

This is the first extension from PECL I really use.

Any idea’s on my problem?

Just a quick note. Would it be a big thing, to also use GET parameter?

This code (simplified) works:

<form action=”/u.php”>
<input type=”hidden” name=”UPLOAD_IDENTIFIER” value=”abc” />
<input type=”file” name=”filename” />

This code doesn’t work:

<form action=”/u.php?UPLOAD_IDENTIFIER=abc”>
<input type=”file” name=”filename” />

Thanks in advance
Markus Doppelbauer

first of all… thanks so much for doing all this. i hope to be using your extension soon.

my hosting company is trying to install the extension for me. unfortunately i don’t have my own server to work with. they have told me that their first attempt to install your extension was unsuccessful…

has anyone had success installing the extension with an apache 1 / cpanel setup? any advice or pointers here would be greatly appreciated.




Suuummeeer: Just read the text in that readme and follow the URLs… or reread the blog post above again, especially the note at the end about “It’s in PECL now”…

And hey, are you related to that guy here:
http://trash.chregu.tv/instructions.txt ?

pfff. maybe its your brother who wrote all that explicit language.

i know more about donkeys, mysql and everything inbetween than you do.

No further comments needed then from my side, mr. know-it-all :)

This blog or article is completely useless, you dont have to deny help when you dont even know how to help others, only reason your article/blog is getting some attention is due to the fact that HOOKS is new feature in PHP 5.2 and not many have published blogs about it yet.

Congradulations on being able to convince yourself that you are a genius by publishing a stupid article and a very poorly designed MOD which does not even have a LIVE DEMO , i am not even going to waste my time going through this article, i know i would be wasting my time , and i feel sorry for anyone who spends time trying to use this
script/whatever only to figure out it is constructed in very stupid ways and completly useless.

Making things look complex and screwing up all just so that it can make you look intelligent might be a good way to get into the spotlight for a while but i don’t think people will accept it, and they cant wait to find an alternative source.

i am sure within a few weeks someone will publish a simple way of using the PHP 5.2 HOOKS with 3 LINES OF PHP CODE. with an AJAX.js included on top. thats all there is to it.

infact eventho i am a newbie at this, i can say it on top of my head that what is needed is a simple
AJAX.JS on top
and a custom.php?tempfile=juice.mov file which can check total uploaded on the temp file in the temp folder every 0.5 seconds.

i am just pissed off that i keep finding this stupid useless article on google everytime i search for php 5.2 upload progress meter.

i guess google’s spot is up for grabs. maybe i should just start a search engine and ban all your useless unnecessarly complicated articles and bs blogs.

I should also add… You are just another Stephen Hawking wannabe, and in my own opinion…

Stephen Hawking is the most retarded, the most stupid idiot alive in the universe.

Funny enough that no one else came up with an easier solution than mine… So I’m still waiting

And your proposed “solution” is not gonna work, but be my guest to prove me wrong…

Anyway, keep babbling, it’s kind of entertaining…

Why dontt you like find a 500 MB pdf or text file somewhere on google and attach it to your project’s files just so it can make you look more of a genius.

It’s nice to the developer actively participating in this thread but the lack of comment regarding the broken windows version is disheartening (when he is so eager to banter with an uncouth user).
Any news on why it doesn’t work/ how to fix it?


I made it hopefully clear enough…

I can’t and won’t fix the windows version. Someone else with knowledge in that area has to step up..

If I would know, why it doesn’t work or how to fix it, I would have done it long time ago..

Your extension just won’t work any longer. It did once after installing php 5.2.1, then when I tried one week later it wouldn’t work. I can’t remember exactly what I did in between so i cannot track it to a change in server configuration or code.

Always getting empty responses from uploadprogress_get_info() nowadays.

I have tried this in php.ini:

But when watching /tmp all I can see is the temporary uploadfile php creates. No upt_%s.txt anywhere!

UPLOAD_IDENTIFIER hidden value is set first in the upload form.

Tried both 0.3.0-beta from pecl and 0.3.1-dev from CVS.

What can I do to debug this issue you think? Uploadprogress is _very_silent about everything, the documentation has no info about troubleshooting and the phpinfo() output is not very useful (only a version number…)…

Disabling the suhosin php5 module makes the upt-file being created. The file is however stale, always containing information about that 5kb has been uploaded.

Going nuts on this. Ideas?

What is this error all about…

object(undefined) (5) {
string(25) “content has no properties”
string(92) “http://XXXXXXXXXXXXX/main/demoserver.php?client=main,request,httpclient,dispatcher,json,util”
string(306) “()@http://XXXXXXXXXXXXX/main/demoserver.php?client=main,request,httpclient,dispatcher,json,util:1065

string(9) “TypeError”

Everything worked fine for a while, not sure what broke.



Can anyone provide me with a list of functions for this extension? I can’t find it anywhere.


It doesn’t work with simultaneous uploads.
Just open 2 browsers and upload two big files simultaneously and the progress bar will fail.

Or maybe I did something wrong. Can you help ?

Are there install instructions on this? I downloaded the uploadprogress-0.3.0.tgz from PECL and can’t find any instructions on how to use it.

Some help with this extension would be great. I’ve installed it on two servers now and they are both reporting the same errors

I’ve put into php.ini

and /tmp has full 777 chmod
However, nothing ever appears in there from this extension and uploadprogress_get_info() always returns NULL. Is there any dependencies that I should be aware of? (other then php5.2 of course)


Also in regards to Ite with Suhoshin, one of the servers has Suhoshin installed, the other doesn’t, but both are failing in the same way (showing just null)

Jude: How does your script look like? Do you try with an large enough file? Is it smaller than the usual file upload ini parameters in PHP?

Hey Christian,

I’m using sample code from here

His archives are a little broken so I had to hunt around for the right code

in part, this is what the important things look like

upload.php –
$unuiq= uniqid();
-in form

– progress.php
$unique_id = $_POST[‘UPLOAD_IDENTIFIER’];
$uploadvalues = uploadprogress_get_info($unique_id);

it always var_dumps NULL as the value

the code from his site has an error as well on progress.php as he is trying to get $_POST[‘uniqu’] instead of $_POST[‘UPLOAD_IDENTIFIER’];

As I mentioned as well, it never shows up anything in the /tmp dir to start off with :-/

Does that php.ini directive need to be in there before the module is compiled into php? Do I have the syntax of that directive correct? Just going out on a limb here as this is the first module I’ve used from PECL and I can’t get it working, hehe

-in form

input type=”hidden” name=”UPLOAD_IDENTIFIER” id=”progress_key” value=”<?php echo $unuiq; ?>”/
input type=”file” name=”file1″/

Quite nice work ! Thanks for this code..

Just adding a bump in here since I didn’t get an answer, hoping that my question didn’t get lost in the shuffle. I downloaded the uploadprogress-0.3.0.tgz from PECL and can’t find any instructions on how to use it. Is there some sort of walkthough or something available to teach me how to incorporate this into my current website? Any guidance is
more than appreciated. Thanks in advance.

Seems we finally managed to make this extension working under Win32. Details about problems we fixed as well as fixed sources & project files and compiled dll you can find at http://www.emforge.org/wiki/AjaxBasedFileUploadForPHP

Not 100% it will work in all cases – we are not very experienced in the PHP extensions development – but it is working in our case

Alexey: Thanks a lot for that. Looks ok, but did you intentionally change

VCWD_FOPEN() to fopen() and if so, why? :)

Do not know there it is better to answer – here or in bug-description – so, will answer in both places:

Yes, we changed VCWD_FOPEN to fopen… As I wrote – we are not very
familiar with PHP Extensions development – and fixed this extension only because we needed it urgently.

We found that if we used VCWD_FOPEN
function – we got ‘lock’ exception from latelly called fprintf or
fgets… Probably, instead of these functions we should also use some
PHP-specific functinos for working with files – I do not know – but
changing from VCWD_FOPEN to fopen let us avoid these problems

Great code… but where’s the doc?
No, the demos mentioned here don’t work at all on my side and I would like to figure out how to use that by my own but without a doc, as I don’t know C++, I can’t figure…


Now I got a demo to work… well, it uploads files… but that’s pretty much what it does… the Progressbar doesn’t work at all. I tried to upload a 7MB file to my remote server. The progress says “connecting” and after a while (2-3minutes) the bar suddenly goes blue and it says “upload complete” — the file is on the server then in the correct
directory though the bar didn’t show a continue progress… it just jumps blue when the upload is ready…
I have no clue at all what’s happening there… Is there something what I have to configure, that AJAX get’s the continues progress without waiting for the upload to finish?


Hey Alexey Kakunin,

Tries your example and the progress bar doesnt work in both IE and FF. In IE the upload soesnt work at all, I just get Uploaded file list. In FF I get a ‘please wait’ for about 2 seconds then bar turns red and then finally I get the results.

I wasnt sure what to do with the ‘uploadprogress’ attachment so I just put the files in the same directory as the upload files.

How if i just want to use php file and javascript file??? not other!

i want use popup msg “please wait file is uploading” in my application when file is uploading
can u help me

Now I got a demo to work… well, it uploads files… but that’s pretty much what it does… the Progressbar doesn’t work at all. I tried to upload a 7MB file to my remote server. The progress says “connecting” and after a while (2-3minutes) the bar suddenly goes blue and it says “upload complete” — the file is on the server then in the correct
directory though the bar didn’t show a continue progress… it just jumps blue when the upload is ready…
I have no clue at all what’s happening there… Is there something what I have to configure, that AJAX get’s the continues progress without waiting for the upload to finish?

Great job, man!

Very good work. Thanks for developers… Scripts work cool.


I am trying to get this extension running for an upload progress indicator. I have done this:

pecl install uploadprogress channel://pecl.php.net/uploadprogress-0.3.0

but the function uploadprogress_get_info is not found. I used the following on the page:

if (!function_exists(‘uploadprogress_get_info’))
echo “uploadprogress_get_info not found


Any clues as to what I am doing wrong ??


I tried a lot codesamples, some basing on uploadprogress some on the apc.rfc1867 hook, but i got the same result with ervery try. both (auploadprogress_get_info() as well as apc_fetch() stay empty till the end of the upload. after upload is finished they report correct data (like size, rate etc…) I tried it with php 5.2.4 on a windows server as
well as with php 5.2.3 on a linx system. everytime the same shit (sorry).
I would be very pleased if someone could give me some advice how to get even one of the functions to work.
Thanks in advance


This wouldn’t work for a windows box, would it? I don’t have the privilege of recompiling. If anyone knows of a way to implement this on the latest PHP version for windows, with apache2, let me know.

Sweet, I’ve been using 5.2 since pre-release and I never noticed that the information was already available, I had actually hacked in the old patch and compiled, had I known I would’ve written an extension but you already have! thanks!

PS. It’s also sweeter because now that I shouldn’t have to patch my php, I can use a packaged version of php, which also enables my app to run on more servers with the simple install of the extension..!

Motin: What’s the problem? The security issue was fixed the day the problem was published and that was before it even was in the PECL CVS (that may explain, why you missed it ). The fix is certainly in the 0.3.0 release available since 10 months here: http://pecl.php.net/package/uploadprogress


Oh sorry, I was mistaken about the cause (I read above about it as “the explanation” but didn’t double check it sorry). It’s just that the extension clearly doesn’t work at all when Suhosin is enabled. The /tmp/php* file steadily increases in size, the form was supplied with the following:

<form method=”POST” enctype=”multipart/form-data”>

but uploadprogress_get_info(‘472314fb68c45’); returns NULL during the whole upload.

Same issue as in my earlier comments above. I am using uploadprogress 0.3.1-dev and php 5.2.1 with apc 3.0.13.

It it’s not the security issue – what is it then?

Comment system stripped out the input – the code should be (trying with htmlentities…):
<form method=”POST” enctype=”multipart/form-data”>
<input type=”hidden” name=”UPLOAD_IDENTIFIER” value=”472314fb68c45″>

where can we found some proper documentation about how is this extension supposed to work? The functions, etc..

I have the script working great (and am really happy with it), but I’m having troubles uploading large files… Once the file hits around 50MB, I get an “Invalid Meter ID” error. All of the php.ini settings are for 1GB.

I need to have the script supporting uploads of up to 700-800MB…

Anyone have any ideas?

I have been using this script for a client who needs to have a dump site. The client base is mostly graphic artists who require file uploads in excess of 200 megs. A few changes required in php.ini to deal with file upload size. Posted example of php.ini in upload.tar.gz. Go to the url posted and download upload.tar.gz. Place user1 folder in html
directory to access from your url. eg.”youcanddns.com/user1″. If unable to do so you can setup a ddns site at home using noip.com free ddns web address. eg. “youcanddns.no-ip.com. The url posted is a small linux home server so please keep file uploads under 5 megs. The example php.ini is setup to handle file uploads up to 1200 megs. Edit all 3
index files to suit your url “name” and alter necessary permissions.
Add index.php to “DirectoryIndex” section of apache.conf or httpd.conf. Edit .htaccess and .htpasswd to change password and user.
Fedora Core 8 with all yum updates.
Clone machine, Athalon 3.2 gig 1000meg ram

user – guest1
password – elvis1

Sorry I haven’t played around with this thing for so long I forgot their is a cgi-bin element involved. Added cgi.tar.gz to site for use as example. You must edit XUploadConfig.pm to suit you’re setup

Nathan, check your web server’s settings as well, as a file limit could be set there.

For people using Windows that get no data from the uploadprogress_get_info function, make SURE you add the following to your php.ini.

uploadprogress.file.filename_template = “C:winnttempupload_prog_%s.txt”

Change the path accordingly to your temp directory.

Hi All

Can u pls help me in configuing it
When i m downloading all source files and uploading it on my server its not working.
I noticed that in demoserver.php line no 20 it requires ‘HTML/AJAX/Server.php’ file(require_once ‘HTML/AJAX/Server.php’).

I browsed the SVN but not found this file.
Can anyone pls guide me from where i will get Server.php files

Thanks a lot in advance

Neetesh Bhatia

My server API is using CGI and also I use Zend Optimizer. Is it conflict with this extension? Coz I don’t get it work. The function uploadprogress_get_info is not returning anything.

I finally get it back to work, but not using this extension. I use a perl script to handle the upload and using AJAX to do another call to monitor the progress of that Perl script. Drop me email to hermawanharyanto@gmail.com if you need more advice.


just tried to use suhosin together with uploadprogressmeter and even with latest cvs build it not creating any tmp upt_*.txt file.
Using Debien etch php-5.2.0+etch10 with php5-suhosin package from apt-get.

No evidence in the suhosin logs…

Thanks for your help.

I’ve spent several hours as well to wonder why the upt_*.txt files are not created.
Actually, they ARE…
But they are deleted when the upload is completed.
if ( event == MULTIPART_EVENT_END )
VCWD_UNLINK( progress->identifier );
So when the upload is fast, you don’t see the file. If you want the file to stay (and since they are small and in the tmp folder, they could stay) then remove the call to UNLINK and recompile.

@Pierre : I know were to look and especially when. I’ve tried while uploading files of 100MB and I do see the upt* file when suhosin is disabled. I just do not see it when suhosin is enabled.


Same here with latest CVS upload progress (downloaded today) and suhosin patch
on Apache-2.2.4 + PHP-5.2.4 + Suhosion-0.9.20.
The /tmp files are not created, if i disable
suhosin it works ok.

That’s a great extension!!!

This is really a great extension. But I found a problem.

While on all browsers it works
on IE7 in Windows VISTA


returns 0

I hope this can be fixed..

This extension, like everything PHP related, is not dependent on the browser you use. The error must be somewhere else

Thanks a lot for this great extension, I just figured out I needed this implementation in a site of mine yesterday, and guess what? I installed the PECL extension with only one try and it seems to work perfectly, looking forward to modifying the source for personal use :) Keep up the great work, Chregu, Doru and Joshua! :)

By the way, Chregu and all the others, do you by any chance know a way of finding the GET query string of the HTTP request inside the uploadprogress_php_rfc1867_file function? I’d like to implement a way of getting UPLOAD_IDENTIFIER from the GET data on my own ;)

I have the same problem as Hermawan Haryanto: the get_info function doesn’t return anything at all. The only thing that’s special about my setup is that I am using PHP in a FastCGI setup.

Mr. Toumal, since we are using FastCGI, every request by browser is having it’s own thread on the server. That’s what makes the function get_info returning nothing. This extension is requesting that all request by single browser is having the same thread on the server.

It’s not appropriate if I give you a different approach on this comments box since it will be out of topic. Please mail me to get more info on how to get it done.

The “different threads” explanation is not true. The extension writes the temporary info into the filesystem and not into memory. So it’s somehow true, that all the request have to go to servers which use the same filesystem for making it work, but certainly not have use the same thread. Otherwise with a pre-forking system like one usually uses in
apache with php, it would never work.

Maybe it does really not work on FastCGi for other reasons, I never tested it, but the “threads-story” is just wrong.

That’s the conclusion that I got coz I saw the threads are all differs for each requests.

Just a suggestion, Is it possible if this extension using the same approach as the perl one does?

And what’s the approach of the perl one?

1. On the HTML form, we give a unique ID on a hidden form field.
2. The extension then take that unique ID and generate a txt file on the temporary directory.
3. Meanwhile accepting the upload, the extension is updating that text file every few milliseconds with two colums (coma or pipe separated) containing the current received on the memory and the total size of the file.
4. After the file is uploaded completely, then save the file to the destination and remove the text file.

By using that approach, we can use another AJAX call to monitor the text file and doing our own display by using the information given on that text file.

What dya say?

That’s exactly how the extension does it… The upload process writes that file defined in uploadprogress.file.filename_template, a second process with uploadprogress_get_info() reads it and returns the data.

Please get a little bit more informed, before making such false assumptions :)

:) Then I have no idea what else to say why does the uploadprogress_get_info() doesn’t return anything on FastCGI installation and I know I’m not the only one who experience it.

If you have spare time, maybe you can test it too on FastCGI installation so you can see it. Perhaps, once you see it, you know why it behave like that.

You were saying “uploadprogress_get_info() reads it and returns the data”. Would you care to share where does that function read on the filesystem? I mean what temporary file(s) to read? Maybe we could manually use built-in PHP method to read that file if that’s the problem.

I desperately want to use this extension since I don’t want to have my site having combination of both language Perl and PHP.

Thanks for the help man and sorry for the trouble.

I doubt, it’s the file reading, which causes the problem, but more the uploading itself. But for what it’s worth:

The filename is defined in the ini variable uploadprogress.file.filename_template, which is by default /tmp/upt_%s.txt, where %s is the id sent in the UPLOAD_IDENTIFIER field.

Hi!I was using APC to handle my upload progress. But I found out that APC doesn’t support multiple users! It means when there’s another user trying to upload, the first user’s progress bar will be disabled.

I would love to know could this uploadprogress extension be using in multiple users situation? thx a lot if someone tell me the answer.

Yes, it can handle multiple users… But I’d be surprised if APC really has a problem with that…

im using lighttpd+php5.2.5 (fast cgi) , and function: uploadprogress_get_info() do not return any thing..

Doesn’t work on my box too. Must be the problem with suhosin mentioned above. The function always returns NULL. I’m btw running 5.2.0-8+etch11 on a debian 4.0 box with suhosin v0.9.12 and uploadprogress 0.9 (php info says it’s 0.3.1-dev tho)

Pelle: Yes, it doesn’t currently work with suhosin. I found the issue in suhosin. I contacted the authors there and I hope, they can adjust it, so it does the same as PHP without suhosin does.

And yes, I forgot to bump up the version number in one file, will soon be fixed

Peopel, you can get progress metter in web server: Lighttpd version 1.5 from SVN.

nice work, but I got the same problem with Fastcgi too.. what can I do?

I just tried to upload a 30MB MP4 file and this is what I got as a result.

Upload succeeded, it took 64.382 seconds.
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…

And? “Maybe it really does not work…” :)

that’s why I was posting it. It says maybe it does not work. Is this something that does not work any longer or is this demo just broken?

Ah, you used the demo :) Your file was too large. upload_max_filesize is 20MB (I will add that info to the demo…)

Thanks for the tip, I used a file < 20MB and it worked fine. Does this use the same size limitations that PHP limits? I mean if we upped the size to 200MB, would this require it’s own limit set or does it piggyback php’s settings?

Yes, it uses the php.ini settings

It isn’t important what size I am using (php ini 150MB), it jumps to 100% after finish..

I’m trying to compile uploadprogress.c via gcc on linux and get the following error:

In file included from uploadprogress.c:24:
/usr/local/include/php/main/rfc1867.h:74: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âintâ

Anyone seen this before or know what to do?

nevermind… got it working

I just tried to upload a 256KB MP4 file and this is what I got as a result.

Upload succeeded, it took 6.145 seconds.
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…

My max upload filesize is 20MB, I am getting a headache over this lol…

Thanks for the work done.

I have a problem on my system.
uploadprogress_get_info() returns always NULL.

Is that a problem of installation ?
A known bug for which there is no answer yet ?

Any idea of how I could change that. I would be so gratefull. I am using it on an Apache2 running on a Debian etch with php5

Download started since 52.104 seconds. No progress info yet

Demo(http://labs.liip.ch/uploadprogresssimple/index.php) is not worked for me.


Your file was maybe too large, then this happens. I’ll try to look into that soon, but until then, that’s a little flaw in uploadprogress

Hi, I am trying to compile php 5.2.8 on win64 (see phpx64 project on the net) and except a few extensions it works.

Unfortunately, in my setup “make” will not even try to build uploadprogress (latest from pecl) since there is no config.w32; I tried to adapt a config file from tokenizer:
// $Id: config.w32,v 2007/08/01 15:13:40 pajoye Exp $
// vim:ft=javascript

ARG_ENABLE(“uploadprogress”, “PECL Upload Progress extension”, “no”);

EXTENSION(“uploadprogress”, “uploadprogress.c”);

however, I will not see any output regarding uploadprogress in nmake’s messages, configured for snapshot build.

Also I noticed that in the makefile it creates an output file “php_uploadprogress.dll”; in earlier x86 versions it was “uploadprogress.dll”.

Can somebody help me with that?

Thanks, Chris

I had the same problem as Franc @ 09.12.2008 10:58 CET

It DOESN’T work with multiple uploads. If you want to track multiple files beeing uploaded by one user, the second upload will return NULL!

Wasted time :(

Any ideas?

Joust: I don’t see, how that technically could happen if you use different UPLOAD_IDENTIFIER ids.

Are you sure you use different UPLOAD_IDENTIFIER ids for the two uploads?

That’s true. Different identifiers, but module creates only the first /tmp/upt* file and the second upload is not monitored…

Joust: Are you using mod_php with Apache? And which apache module are you using?

PHP Version 5.2.6, Server API: Apache 2.0 Handler, Apache 2.2.9 on Linux, module 0.9.2 dl and compiled directly from PECL.
Thanks for your time :) You can email me if it’s more convenient for you.

In all the demos I’ve found online and my own code, the meter shows ‘waiting to upload’ throughout the upload and then jumps straight to ‘Upload complete’ when I reset the cookie at the end of the upload.

uploadprogress_get_info() always returns NULL, so the actual progress is not shown. Can confirm that the temporary progress file gets created and sometimes deleted, sometimes not, at the end of the upload.

Using Apache 2.2.9, php 5.2.6.

eric t.

… on a Windows Vista system, that is.

1. Is there any way to tell uploadprogress_get_info() to check a directory other than /tmp? We are using nginx to load balance and it distributes the file uplods to /tmp/0 through /tmp/9 on a random basis. The problem is that uploadprogress_get_info() only checks upload_tmp_dir, which happens to be /tmp. Anyone know how a workaround besides
updating the PECL code?

2. Does this work with suhosin yet?

John: uploadprogress_get_info() puts its own files into tmp and doesn’t need the uploaded files, so this has not much to do with each other.

The main issue is more, that maybe it doesn’t work with nginx at all, but I didn’t test it.

2. It works with suhosin since the August release of suhosin.

See also my latest blogpost at http://liip.to/X0 for more info about some common issues

… and it still won’t do multiple simultaneous files from the same session…

Joust: Please send me the smallest possible code you can reproduce that (or even better open a bug at http://pecl.php.net/bugs/report.php?package=uploadprogress ) I still can’t see, how you run into that problem.

Did you also read the section “The position and content of UPLOAD_IDENTIFIER within the form is important” in http://liip.to/X0 ?

From where i get code without patch

Saji: You don’t need to patch anything anymore if you have PHP 5.2

After hours of struggle, I’ve found that this extention does not work well if apc.rfc1867 is on. Can anyone confirm my findings?

awesome work.Was looking for upload meter for last 2 hours.This one is great

I kept a backup of a working html folder on fedora 8 and 10. All you need to change are the url’s on one file and install php. Modifications to php.ini and http.conf are included in the backup. In the middle of a move right now. Will post at youcanddns.no-ip.com

Is there a tutorial on how to install this. I feel pretty lost without a step by step tutorial but i really would need this module. Can I load it without recompiling, reinstalling Php??

APC_UPLOAD_PROGRESS must be defined before the type=”file” input, else it won’t work!!

I’ve looked everywhere to try to sort out how to do this. Now I’ve tried every possible way to get this to work..

I have php 5.2.0, I tried getting a progress meter to work with apc.rfc1867, but was unable to do so, and alas came across this extension. I now have the PECL extension installed, but can’t seem to ready anything from uploadprogress_get_info()… The upload will start, and the progress bar will jump straight to complete, while the upload carries
on in the bg.. can be seen here:


Any help is appreciated


The extension worked for me just fine before I moved to a new server. And stopped. I found something here blog.php-security.org/archives/58-Suhosin-caught-another-remote-code-execution-vulnerability.html
That’s not solution but explanation.

I still cannot use this due to the canary heep overflow bug that Suhosin spots (blog.php-security.org/archives/58-Suhosin-caught-another-remote-code-execution-vulnerability.html).

Does the author intent to develop this extension further or is it good enough as it is – only working on insecure environments?

Thanks for the extension it’s a pity many can’t use it…

Uploadprogress just does not work with FastCGI, even no workaround possible.

Since 2008 no solution, see:

Bug #14400 with php FastCGI do not work >>> pecl.php.net/bugs/bug.php?id=14400