Drupal 7 Increase Max File Upload Size

By shane
Wed, 2012-12-12 12:14
3 comments

Share with Others

Have you ever ran into a problem where you needed to upload relatively large files and still want to be able to manage these from the Drupal 7 administrative interface? If so, you may run into a situation like the one below:

You will notice the 12 MB text stating that we can only upload files that are 12 MB and under. In this case I needed this number to be a little bigger.

In order to do this you will need to modify your PHP settings in your php.ini file.

Note: You should make sure you know what you are doing and understand the consequences of increasing this number. In my case this is on a site that only users that I trust will be uploading files. If you allow any user to upload files, increasing this number can add an increased load on the server and possible eat up your disk space pretty quickly.

Now that you have been warned, here is how I was able to do this. I first found the php.ini file on my system. I am on an Ubuntu server so I was able to get to edit mine using vim like so:


vim /etc/php5/apache2/php.ini

Change the upload_max_filesize setting

The first step was to find the upload_max_filesize setting from 12MB to 30MB.

Change:

To:

Change the post_max_size setting

You may also need to modify the post_max_size setting. I changed the post_max_size php.ini setting from 20MB to 30MB.

Change:

To:

Restart Apache

You will then need to restart or reload apache so the changes take effect. I simply restarted apache using the following command:


service apache2 restart

After that I simply refreshed the page on my Drupal 7 site to see:

Pretty simple! I hope it helps you if you need to increase the max file size of a Drupal 7 file upload field.

Comments

It might be worth mentioning that there are other methods of setting these values, like .htaccess & the drupal settings.php.

A lot of people may have hosts that restrict access to php.ini but they might be able to override via settings.php.

Also, if people don't know where their php.ini is they can use php -i from the command line to get phpinfo.
Or they can create a file like pinfo.php that contains:

<?php
  echo phpinfo();
?>

in their website root and then go to mysite.com/pinfo.php to see the php info information in a more readable format.

Post new comment