All of the upload progress meters that I've run across only include the file upload field by itself, which is not realistic in an actual web application situation. You will most likely be entering other information along with uploading a file. The demo is an adaptation this php file upload progress meter.
Single File Upload
Multiple File Uploads
YUI Code Library
You need this to display the progress meter bar. Look at demo source code for essential JS files.
Requirements:
You must have APC (Alternative PHP Cache) and PHP 5.2 installed on your server for any of this to work.
This is really the only potential problem for those who don't have root access to their server. It's not that difficult to install, but you either have to have root access, or your hosting provider will need to do this for you. The script will definitely not work without this.
Installing APC on your Linux server
Installing APC on your Windows server
Important: Make sure to include apc.rfc1867 = on in your php.ini file after APC is installed. Your php.ini file should be located in the /etc/ directory.
Resources
Upload Progress Meter by Rasmus Lerdorf
This is where the majority of my script came from. In my opinion, this is the best and cleanest php upload progress meter on the web.
"Check the following:
1. Use phpinfo() to see if APC is really installed.
2. Make sure your folder has full write permissions (777). If you're uploading to the folder where you files reside, then that folder must also be set to 777.
"
"HI john
Thanks for your quick response.
All things were in place. The problem was related to the caching of my browser.
Now it is working fine.
But now when i am uploading a file , all time during uploading progress bar does not move. But after some time file uploads successfully.
Any idea Please........"
"Does it work correctly if you use the exact code that I've used? "
"Yeah it does, Apart from visualization of "progress" of progress bar "
"i am already using apc.rfc1867 = on in my php.ini.
i am using yui 2.6.0. Does that make any difference?? "
"@sandeep
check for "progress.php" file reference in john's code. change this filename according to your filename. i copied his code and saved it as "index.php" obviously, it didn't worked, then i renamed the file to "progress.php" and it worked. i also used the same YUI files as john's. Hope it helps
@John
Gr88888 work man, i m definitely gonna use it in my office projects :)"
"I believe Sandeep's issue was that he was testing it locally, so the file uploaded instantly, thus not showing any incremental progress on the progress bar. Also, you can rename the progress.php file and do a find/replace to replace 'progress.php' with the name of your file."
"Hi Jhon,
I saw the demo of your script it's looking good. Here i have one doubt. I already having my own uploading script. From there i am able to upload files into my server properly. I want to integrate the progress bar of your script into my script. I cant install your whole scrit for file uploading because i have many options in the backend in my existing script, so i want only the progress bar module of your script. Can i extract that part and use in my script? If yes please guide me.
Thanks
Phani Krishna"
"Phani - I would need to see your current code to determine how you should integrate the progress bar. Feel free to email it."
"Hi John, this is a neat script! Thank you.
I have a working php script to handle my uploaded files. Now I would like to use your / Rasmus' script to do the upload. But I don't know where I would refer to my script or do move_uploaded_file(). Could you give me a hint? Thanks, Andy"
"hi john,
is there a way to get an error-message if the text-field is empty - before starting the upload script? can you help me?"
"Is there a way to check the size with APC and then stop the upload if the file is bigger than 10 MB ?"
"Hi,
i want to use these beautifull script.
when i am uploading a file , all time during uploading progress bar does not move. But after some time file uploads successfully.
i've try this with your code but there is the same problem.
here my apc configuration, is a mistake?
apc
APC Support enabled
Version 3.1.0-dev
MMAP Support Disabled
Locking type File Locks
Revision $Revision: 3.151 $
Build Date Nov 8 2007 23:20:54
Directive Value
apc.cache_by_default On
apc.enable_cli Off
apc.enabled On
apc.file_update_protection 2
apc.filters no value
apc.gc_ttl 3600
apc.include_once_override Off
apc.localcache Off
apc.localcache.size 512
apc.max_file_size 50M
apc.num_files_hint 1000
apc.report_autofilter Off
apc.rfc1867 Off
apc.rfc1867_freq 0
apc.rfc1867_name APC_UPLOAD_PROGRESS
apc.rfc1867_prefix upload_
apc.shm_segments 1
apc.shm_size 64
apc.slam_defense 0
apc.stat On
apc.stat_ctime Off
apc.ttl 0
apc.user_entries_hint 4096
apc.user_ttl 0
apc.write_lock On
any idea?
i'm sorry about my bad english, i'm from germany.
thanks."
"Am I misreading the manual where it says:
Note that the file upload tracking is not threadsafe at this point, so new uploads that happen while a previous one is still going will disable the tracking for the previous.
Does this mean that this will cause problems with two concurrent file uploads? eg. progress bar for one person fails if another person starts uploading?
"
"Hi John, you're post is fairly recent and I'm hoping you can help me with my APC woes. I have a site where I'm attempting to run your code. The site is multiplesmarket.com/UploadDemo.php. The problem I'm having, and that I have with my own tests, is that apc_fetch just doesn't work.
I've copied the php file, the specified YUI files, and I have APC enabled (multiplesmarket.com/info.php). Can you take a look? By default, my host runs Apache 1.3. I'm wondering if that could be it."
"Josh - I'm not positive what could be causing the problem you're running into, but my guess (like yours) is that it's either that you're not running Apache 2 - or your server is running Apache in CGI mode (Server API CGI/FastCGI)."
"Hi,
I have tried this out, but the problem is, after pressing the submit button, on a fraction of a second the progres bar seems displayed, but after that, it displays some text like
{"total":9372,"current":9372,"rate":74976,"filename":"exchg_myoffers_main.tpl.html","name":"file","temp_filename":"\/tmp\/php1663g0","cancel_upload":0,"done":1}
What may be the problem? I saw in the code, style.css is included.. Fomr where does I get this style ?
Thanks in advance
Subeesh"
"Hi Johnboy,
I have your demo running quite well in my local server but I would like to integrate it in a complex form that I am developing.
This form has a lot of hidden input fields and several buttond to download files and go back to other form which uses the hidden input field in this one.
Is there any way to run you progress bar iframed to avoid data lossess? You use GET to pass the key, so I loss all the form data!
Thanks in advance
"
"Hi Valentin
Important: Make sure to include apc.rfc1867 = on in your php.ini file after APC is installed.
look bellow
...
apc.report_autofilter Off
apc.rfc1867 Off ----> here
apc.rfc1867_freq 0
..."
"In my example, they are stored in the same directory with the upload script. You can set the location yourself here:
$uploaddir = ""; //set this to where your files should be uploaded. Default is same directory as script.
Example:
$uploaddir = "files/"; //set this to where your files should be uploaded. Default is same directory as script. "
"So anyway way to get this going if running Server in CGI Mode? apc_fetch() just returns false...
"
"Dear Sir,
I am trying for image displying loading status bar using ur progress.php script and I have installed and configured php_apc in my php.ini file. Also I have enabled apc.rfc1867 = on in php.ini file. But when I executed this file it will show uploading file window but progress bar is not moving and file uploading is not done.
It is showing error like 'rate' is null or not an object.
Please reply me soon.
Thanks in advance
Regards,
Chaitra"
"The uploader seems to work but only shows 0% and 100%?
Try to upload a bigger file and it will say at 0% for a wile. Then it goes to 100%."
"Works without any problem.I tested locally,uploaded about 90-100mb without any problem.
But i want to show user the uploaded file s name,how can i do this?"
"i solved previous question.
Now i want to post $uploaddir;$filename; variables to upload.php and show user the uploaded file name and directory using upload.php
I used action="upload.php" but variables on progress.php aren t sent to upload.php.
Any solution?
"
"Is there any reason this would not work 'as is' in firefox 3? I have it working perfectly in IE, but I get exactly the same issue as Subeesh:
" I have tried this out, but the problem is, after pressing the submit button, on a fraction of a second the progres bar seems displayed, but after that, it displays some text like
{"total":9372,"current":9372,"rate":74976,"filename":"exchg_myoffers_main.tpl.html","name":"file","temp_filename":"\/tmp\/php1663g0","cancel_upload":0,"done":1}" Really like the simplicity of this but this one bit is killing me....
Appreciate some ideas.
Thanks
Alex.
"
"Can you confirm this will work with the latest verion of yui 2.8.x as I wasn't able to out of the box"
"Hi John,
i am on shared hosting and have run phpinfo. What am i looking for to see if APC is installed?
as i have copied your script, the progress bar pops up but nothing animates and doesn't upload the file.
thanks"
"Thank you! It's excellent code!
But I have 3 question:
1. How to update current Rate upload?
2. How to Stop Uploading (a button to stop upload)
3. How to Seperate each file in each upload (not include all file in upload progress bar)"
"the apc_fetch always returns false during the file upload but returns the array value only once the upload is get done. Any idea?
Runtime Settings
apc.cache_by_default 1
apc.coredump_unmap 0
apc.enable_cli 1
apc.enabled 1
apc.file_update_protection 0
apc.filters *
apc.gc_ttl 3600
apc.include_once_override 0
apc.max_file_size 1M
apc.mmap_file_mask
apc.num_files_hint 1000
apc.report_autofilter 0
apc.rfc1867 1
apc.rfc1867_freq 10k
apc.rfc1867_name APC_UPLOAD_PROGRESS
apc.rfc1867_prefix upload_
apc.shm_segments 1
apc.shm_size 30
apc.slam_defense 0
apc.stat 1
apc.stat_ctime 0
apc.ttl 7200
apc.user_entries_hint 4096
apc.user_ttl 7200
apc.write_lock 1"
"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.
"
"Hello,
Greetings of the day...!!
However, I have run your code in Local Server Wamp, I face below issues.
When i am uploading a file , all time during uploading progress bar does not move. But after some time file uploads successfully. How?
I have APC installed as well as YUI library.
Kindly co-operate me to run this code.
Thank you,
With kind regards,
Dave JC"
"hey there,
I got similar issue as DAVE with running script, i dont see progress bar. I have installed everything properly - Php apc is ok. After downloading i goto only string:
{"total":2047000,"current":2047000,"filename":"eng.mp3","name":"file","done":1,"start_time":1280755391.5058}
In firebug in firefox is an error during pushing the button submit: Break on ErrorKopiuj
YAHOO is not defined
(61 line: YAHOO.util.Connect.setForm(formName,true); )
Any ideas to resolve ?
Thanks in advance"