// index

hyrme.com

Making the upload progressbar in drupal

One of the major problems I have found in drupal sites which allow file uploads is the lack of information displayed while uploading a file. This can get quite frustrating for large files . I was able to figure out a way to enable the progressbar shipped with drupal to show something useful.

To get it to work you will need a few things:
Before making changes to drupal setup your PHP environment:

  1. PHP 5.2 and above
  2. The APC extension installed and configured to collect upload progress information.
  3. Test and make sure that this setup actually works.. You can read more about configuring and setting PHP up here:
    http://www.whenpenguinsattack.com/2006/12/12/how-to-create-a-php-upload-...
  4. Or just download the files here unzip into your document root folder and point your browser to http://yoursite.com/yui/test-apc.php
  5. Make sure your ajax upload in drupal works. Upload a file attachment or a filefield in CCK and see if the upload "bar" shows up.

Now if you are running a FastCGI or CGI mode on PHP the APC approach will not work - instead you will need to download/build and install the uploadprogress module from here http://pecl.php.net/package/uploadprogress

  1. Download (build) and install the uploadprogress extension - make sure that it is included in your php.ini
  2. Set the following variable in your php.ini
    uploadprogress.file.filename_template=/tmp/upt_%s.txt and replace "tmp" with the appropriate temporary folder. If nothing available you can try using the drupal files folder.
  3. download the test program here, unzip into your document root folder and point your browser to:
    http://yoursite.com/yui/test-up.php, upload a file and see if you get any progress information.

Assuming you got one of the above approaches working..

Our next step is to get drupal to work with the information provided above.

  1. download the uploadprogress module here..
  2. patch your upload.js file to actually get the upload information. The 5.X head patched version of upload.js is included in the zip file.
  3. copy the upload.js file to the misc folder
  4. install the uploadprogress module.
  5. configure the module in admin/settings/uploadprogress and select either the APC extension or the uploadprogress extension. Note if either extension is missing the settings form will not display that as a selection.
  6. upload a file now..

Progressbar not working - but your tests worked?

  1. Ajax uploads not enabled in drupal. Make sure that your filefield is able to upload a file via ajax without the progressbar changes.
  2. not all file fields support AJAX upload in drupal. See here for a patch to the mediafields http://drupal.org/node/132233.
  3. Anything else? leave me a comment below.

uploadprogress exstension not working with lighttpd

php-5.2.5-rc6
lighttpd-1.4.18

Extension installs nicely, is loaded, but /tmp/upt_%s.txt doesn't get created. Thus progress.php outputs:

"{"done":0,"total":null,"current":null,"rate":null}"

Scratching my head for 2 days now and counting...

you are using the

you are using the uploadprogress extension. Is your temporary file folder writable by your webserver?

Also possible that the extension does not work with lighttpd as I have not tested it out.

This is the best and short As i found---

UPload Progress bar PHP

<< INSTALL IN WINDOWS >>
1)Get the latest php-5.2 or > installed on system,.
2)Download dll
"upload progress" php extension here : http://pecl4win.php.net/ext.php/php_uploadprogress.dll
place this dll in php extension directory.For me this is d:/php/ext

3)then put it in extensions directory in php
Change php.ini :
Code:

extension=php_uploadprogress.dll
[uploadprogress]
uploadprogress.file.filename_template=”C:\xampp\tmp\sometext_%s.txt”

Thats all..!!!!
uploadprogress_get_info() function is available for u.

<< INSTALL IN LINUX >>
Code:

## Get the latest lampp package (as of writing 1.6.4)
wget http://switch.dl.sourceforge.net/sourceforge/xampp/xampp-linux-1.6.4.tar.gz

## Get lampp devel package
wget http://switch.dl.sourceforge.net/sourceforge/xampp/xampp-linux-devel-1.6...

## Extract both in the same /opt directory

## Get uploadprogress extension from PECL
wget http://pecl.php.net/get/uploadprogress-0.3.0.tgz

## Extract, build, install
tar xvzf uploadprogress-0.3.0.tgz
cd uploadprogress-0.3.0
phpize
./configure
make
make test
make install
vi /opt/lampp/etc/php.ini
uploadprogress.so ;under extensions
[uploadprogress] ;at the bottom will do
uploadprogress.file.filename_template=”/tmp/uploaded_%s.txt”

shows progress but file doesnt get attached

for me, it shows the progress for smaller files, for big files it doesnt show progress.

and even for the ones it shows progress, the file doesn't get attached.

If the file size exceeds the

If the file size exceeds the max file upload settings in your php.ini then you will see this behavior. Make sure that the max_file_upload and max_post_size are both set to large enough values to support your uploads.

a nasty bug

I've spent many hours tracking down this bug: http://drupal.org/node/217205 (multiple calls to uploadprogress_form_alter breaks progess monitoring)

If progressbar's not working and you have 404 erros in your logs with an url containing something similar:
http://incontext.sch.bme.hu/upload/progress/,/upload/progress/47a4fd6141...
than your really should have a look at that bug.