How to increase the file upload size in your php.ini or .htaccess file?

Drupal's limits on upload file size are determined by the settings in your content types (image, video, file, etc.) AND by your server's PHP settings ). The default values for PHP will restrict you to a maximum 2 MB upload file size.

On the settings page for the upload module, Drupal calculates and displays the maximum file size that you can set based upon two PHP settings: 'post_max_size' and 'upload_max_filesize'. Since 'post_max_size' is the limit for all the content of your post, many people choose 'post_max_size' to be a multiple of 'upload_max_filesize' to allow multiple files to be uploaded, but this is not essential. The upload module limits the size of a single attachment to be less than either post_max_size, or upload_max_filesize, whichever is smaller. The default PHP values are 2 MB for upload_max_filesize, and 8 MB for post_max_size.

Depending on your host, changing these two PHP variables can be done in a number of places with the most likely being PHP php.ini file or .htaccess file. (depending on your hosting situation). In the following example we increase the limit on uploaded files to 10 MB and the limit per post on 50 MB.

Step 1: 
Find out your PHP configuration

The steps in updating the values listed in your PHP info page depend on how PHP is setup on your particular server. In general, PHP runs on our servers as either:

- Apache module
- CGI Module

To find out how PHP is configured on your server, create a PHP info page (via the instructions in How can I see my php settings) and look at the "Server API"' value. If the "Server API" is "CGI", then PHP is running as "CGI module". If "Apache" is listed, then your server is running PHP as an "Apache module".

Step 2: 
Server API: Apache -> .htaccess file

If your server runs PHP as an "Apache module", you can update your PHP settings via a .htaccess file. A .htaccess file is a configuration file you can create and use to update many server settings, including PHP settings. The basic syntax to use in your .htaccess file for updating PHP settings is:

php_value Directive value

In our example we add/change the following to your .htaccess file:

php_value upload_max_filesize 10M
php_value post_max_size 50M

After making this change, refresh your PHP info page, and you should see the changes. If you receive a 500 error, please double check the syntax you used as you may have made a misspelling.

If you don't have a .htaccess file, you can simply create a new file named .htaccess. As the .htaccess file begins with a dot (.), it is considered a hidden file. If you are using the cPanel's File Manager, please be sure to select the option to Show Hidden Files (dotfiles), otherwise you will not be able to see your .htaccess file. If you do not see this prompt when opening your File Manager, click the, "reset all interface settings" link at the bottom of your cPanel to reset your File Manager settings.

Step 3: 
Server API: CGI -> php.ini file

If your server runs PHP as a CGI module, you can update your local php.ini file in order to make modifications to your PHP setup. php.ini is a PHP configuration file with a list of PHP directives and their values. If you open your php.ini file and search for max_input_time, you should see something similar to:

; Resource Limits ;

upload_max_filesize = 2M
post_max_size = 2M

In our example we change/add the following:

upload_max_filesize = 10M
post_max_size = 50M
File upload Drupal

Drupal themes to be compared