Skip to main content
  • X Twitter
  • youtube
Home
Drupal 4U
Built for AI. Powered by Drupal.
  • Home
  • Showcases
  • Services
  • Blog
  • Themes
  • About
  • Contact

Breadcrumb

  1. Home
  2. HowTos
  3. How to increase the file upload size in your php.ini or .htaccess file?

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

HowTos
May 18, 2013
Profile picture for user drupal
By drupal
  • facebook-f
  • twitter
  • envelope
  • print
506

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.

Solution

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
How to increase the file upload size in your php.ini or .htaccess file?
Configuration

Read more articles

Newer
How can I see my php settings?
Older
How to enable Superfish menu in Danland/Danblog theme?
  • Log in to post comments
Profile picture for user drupal
drupal
506
2
min read
A- A+
  • facebook-f
  • twitter
  • envelope
  • print

Contact Us

Get in touch for questions and our Drupal development, design and optimization services.

Contact Us

We aim to reply the latest within 48h.

Drupal 4U: Built for AI. Powered by Drupal.

We are a group of Drupal designers, developers and webmasters. We are Drupal experts! We provide comprehensive services that go beyond traditional web development, focusing on how AI understands, interprets, and cites your content. With our deep expertise in Drupal's architecture, we build the intelligent core of your digital presence, ensuring your brand remains authoritative and visible in a world where AI is the primary gatekeeper of information. Partner with us and let's future-proof your digital strategy together.

  • X Twitter
  • youtube

Drupal Services

  • Drupal Web Design
  • Drupal Development
  • Drupal SEO
  • Drupal GEO
  • Drupal Migration

Drupal 4U

  • Services
  • Showcases
  • Themes
  • Blog
  • About

Drupal Links

  • Official Drupal Website
  • Theme Forest
  • Gaivas Themes
  • More Than Themes
  • DXPR: Drupal for Marketers
  • Drupal Answers
2012 - 2025, Drupal 4U

Footer menu

  • Contact
Home
Drupal 4U
Built for AI. Powered by Drupal.
  • Home
  • Showcases
  • Services
  • Blog
  • Themes
  • About
  • Contact
Clear keys input element