Install PECL
FileField and ImageField 3.0 have just been released and bring with them the ability to display an upload progress meter in the FileField widget while a file is being uploaded. As ImageField uses the FileField widget this works for ImageFields too.
The original article FileField and ImageField 3.0 for Drupal 6 Released points out:
Probably the most exciting improvement is the addition of upload progress indication. This enhancement requires the PECL uploadprogress PHP extension, but adds a real asset to sites that use FileField for podcasts, videos, or other large files.
It took me a while to figure out how to install this extension so I thought I'd do a quick post about it. These instructions are probably valid for other PECL extensions but since this is the only one I have installed I wouldn't like to say for sure.
Installation on Unix/Mac
pecl install uploadprogress
-
Download the PECL uploadprogress extension
-
Extract the uploadprogress-1.x.x.tgz archive, cd into the extracted folder and run these commands in Terminal:
phpize # prepares the PHP extension for compiling
./configure
make
sudo make install -
Check that the directory for the extensions is correct. The last line of the output returned from the
make install
command (on my system) is:Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20060613/
Open php.ini and edit the extension_dir
directive, replacing it with this path.
- Add the extension to php.ini by adding this line
extension=uploadprogress.so
- Restart apache
You should now have the PECL uploadprogress extension installed.
Installation on Windows
It's very simple to install on Windows:
- Copy the uploadprogress.dll file from pecl4win into the path set for
extension_dir
in php.ini. - Add the following to php.ini:
- Restart apache.
The pecl4win site was down for maintenance at time of writing so you could try here in the meantime (thanks to chriscohen for the link).
If you're using using WampServer 2 then it already comes with php_uploadprogress.dll installed (thanks again to chriscohen for pointing this out and testing that both methods work).
Increasing Maximum Filesize
To increase the maximum filesize you need to set 2 directives:
- upload_max_filesize - Maximum allowed size for uploaded files.
- post_max_size - Maximum size of POST data that PHP will accept.
Generally you should set post_max_size
to double what you set upload_max_filesize
to. This means you can upload 2 files of your maximum limit for each POST and seems like a good middle ground.
The memory_limit
directive should also be set above the value of post_max_size
so your server can handle the uploads.
There are 2 ways you can set this directive:
php.ini
Edit php.ini and modify these directives:
post_max_size = 256M
.htaccess
Edit .htaccess and add:
php_value post_max_size 256M
Adjust 128M and 256M with the sizes you require.
Increasing PHP's Memory Limit
You could edit the memory_limit
directive in php.ini but I personally like to set that directive on a site-by-site basis. This helps to keep sites that don't need such a large memory_limit
nice and efficient.
Instead you can set the directive in settings.php by adding this line just below the other ini_set
lines: