AttachmentSize
filefield-maxsize-1.png56.21 KB

Last updated April 3, 2009. Created by quicksketch on April 3, 2009.
Log in to edit this page.

FileField checks several server configuration options to help the administrator configure the field correctly. It is simple to configure a maximum upload size, but often times the server configuration prevents the administrator from increasing the size to the desired level. If the server configuration is limiting the value of the field, you may need to adjust the server configuration to allow larger sizes.


An example of the server configuration preventing a larger upload size. Though the administrator might increase the value to 20M, the server will still restrict the user to only 2M.

Increasing the Limit on Your Server

There are many approaches to increasing the maximum upload size on your server, even if you don't have root access or if you're on a shared host. Below is a list of possible ways to increase the upload size.

Change the settings in php.ini

If you have root access on your machine, this is the most reliable and universal approach to increasing the maximum file upload. Find the php.ini file. The most common location for php.ini is /etc/php.ini. If the file is not there, you can determine where php.ini lives by using the phpinfo() function. This reference at PHP scripts might help find the php.ini file using phpinfo().

Once you've located php.ini, there are two settings you need to change, the max post size and max file upload size.

; Maximum size of POST data that PHP will accept.
post_max_size = 2M

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

Change these values to the maximum upload size you would like to allow. After making the changes check that the changes have been applied by checking phpinfo() or the

Create your own local php.ini file

Many shared hosts allow you to create your own minature php.ini file that overrides the defaults of the main server php.ini file.

This approach is known to work with the following hosts:

This file usually resides in the public_html directory of your site, in the cgi-bin, or in your home directory. If the file doesn't exist, just create a new text file named php.ini and include the following text:

; Maximum size of POST data that PHP will accept.
post_max_size = 2M

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

Change these values to the maximum upload size you would like to allow.

Change the settings in .htaccess

On hosts that do not allow local php.ini files, many will let you change settings in .htaccess files. Drupal comes with an .htaccess file that should be uploaded to your server in the root of the Drupal installation. You may edit this file to set additional settings.

This approach is known to work with the following hosts:

Between lines 25 and 53 (in Drupal 6) there are configuration sections such as this:

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
  .....
</IfModule>

Drupal already sets several settings in this file, be sure to add the setting to the appropriate section based on your version of Apache and PHP. If you're not sure what version you're using, it's safe to add these values to all three sections (PHP 4, Apache 1; PHP 4, Apache 2; PHP 5, Apache 1 and 2).

  php_value post_max_size                   2M
  php_value upload_max_filesize             2M

Change these values to the maximum upload size you would like to allow.

Using ini_set() in settings.php

Although many other PHP settings are configurable by using ini_set() in the settings.php file, the post_max_size and upload_max_filesize options are not useful to change with this method, since the settings.php file is not loaded until after the file has been uploaded. Try using the php.ini or .htaccess approach.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

Php.ini method works with an hosting also

So I followed the instructions for Dreamhost. Created a custom php.ini. I was getting so frustrated, checked my .htaccess, checked settings.php and changed everything to the appropriate value. Nothing! I then checked my host settings and those were correct.

Just run
killall -9 php5.cgi

then
touch $HOME/example.com/cgi-bin/php-wrapper.fcgi

then refresh your browse on the 'File Upload Settings' page and you will see the changes.

I was able to change my max upload size with OpenSourceHost using the .htaccess route.
(I did try the php.ini route without success)
I have a starter package with shared hosting... so they were not going to change the php.ini file for the main php settings on the server.
Downloading and editing the existing .htaccess file on the root Drupal directory did the trick.

I believe the BlueHost link under "Create your own local php.ini file" has changed. You might have better luck going to: http://helpdesk.bluehost.com/index.php/kb/article/000110

I've tried this a number of ways. Consistently I get error messages when adding the suggested lines on .htaccess in the directory where I installed drupal 7. When I undo the changes the errors stop. When I create a php.ini file as instructed and upload to the same directory I get errors. Deleting the file ends the errors and I get my pages back, but I'm still stuck with a 2 MB limit.

So frustrating. I've uploaded the php.ini file to the root folder. That doesn't create errors but I'm still stuck with a 2 MB limit. Did the same at the public_html folder. Same results. The only directory adding the php.ini file effects is the one where I installed d7. It gives me error messages. When adding the php.ini file the message I get is Fatal error: Class 'PDO' not found in /home/username/public_html/domain.com/members/includes/database/database.inc on line 185

I installed d7 in the domain.com/members directory.

James
I am developing the ghost machine. While it's under development I need help from drupal experts to provide a prelaunch site. Contact ghosthour.com

I have been for a while unable to solve this problem.
I have succesfully changed my php.ini file to upload images bigger than 2 Mb and even drupal shows me now the max size allowed is 15M but I am still unable to upload images bigger than 100Kb and still get the "HTTP error 0 ocurred" message.
Anybody could give me a clue or advice of what I could do the solve this problem? I think it has to do with my hosting configuration since I have made a mirror copy of my site in my computer and I am able to upload images of all sizes. However when it comes to the live site it does not work, I already changed upload_max and post_max in the php.ini of my server so don't know what else I could do.

To increase the file upload size on a GoDaddy Shared Hosting account, follow these directions:
http://support.godaddy.com/help/article/1475/what-is-the-php-upload-limit-on-linux-hosting-accounts?locale=en&ci=46061

Basically, add or edit the php5.ini file and add the following:

file_uploads = On
post_max_size = 50M
upload_max_filesize = 50M

Upload size can be increased up 64M or 128M depending on the hosting plan. Read for more details.

I've been down this road so many times lol. I wanted to just point out that I had a php.ini in 2 places. The one place it shouldnt have been cuased me a major headache. Maybe I could save someone some time if it happens to them as I went through all the problems so many times :(