Home  »  ArticlesGuidesTipsTutorials   »   Here’s How to Increase the Max File Upload Size in WordPress

Here’s How to Increase the Max File Upload Size in WordPress

As you go into your forays with WordPress you may encounter some errors that really have nothing to do with you. In fact, let us not call them errors but a language feature built into PHP to restrict the sizes of uploaded files and for good reason that is. To fix this we need to look at the max file upload size.

There are several ways in which you can take a peek at this maximum file upload size threshold. For most of them, you need some decent level of technical experience with Apache or Nginx servers.

In WordPress, though there is a much simpler way. In the Admin section, on the menu, you can go to Media > Add New or Media > Library > Add New. You will then be presented with the File upload form and there it will show the maximum file size that you can upload. See the image below.

WordPress File Uploader

Depending on the native setting of your host, this figure may be too low especially if you are trying to run a website with downloadable resources like PDF documents or images.

Three Ways to Change the Max File Upload Size

Here we will show you three ways to change the max file upload size.

Method 1. Using .htaccess

You can use the .htaccess file found in your WordPress root directory. You can normally access this file by logging into your website’s directories using an FTP client or the File Manager provided by your web hosting provider.

This file is processed on demand every time a visitor accesses your website. Like any file, we recommend you take a backup of this file as it stores very critical configuration information for your website.

All you need to do is add the following lines of code at the end of the file and save it back to the server. The changes will then reflect immediately.

php_value upload_max_filesize 32M
php_value post_max_size 32M
php_value max_execution_time 180
php_value max_input_time 180

It is also a good idea to increase the max execution time. In the example above it is set to 180 seconds (3 mins). This amount should not be too high as it could cause more problems on badly written scripts.

Method 2. Using php.ini

Depending on how your hosting plan is set up, you might be given access to the php.ini file. In most cases on shared hosting plans, you will not have access to this file. Though we do not strongly recommend doing this, you can create the file and upload it to your website’s root folder. In which case it is better to stick to the .htaccess file.

Should you choose to proceed with the php.ini file in your webroot you will probably want to secure it by adding the following piece of code in your .htaccess file to keep prying eyes away from it.

<Files php.ini>
Order allow,deny
Deny from all

Now in your php.ini file whether in the correct location or the webroot, you will need to add the following code to the file.

upload_max_filesize =32M
post_max_size =32M
max_execution_time =180
max_input_time =180

Method 3. Using the ini_set PHP Function

This PHP function can be used to set the value of a given configuration option on demand. The lifespan of this configuration lasts until the end of script execution. Or in short, t lasts for that single request.

To set the appropriate configuration options, you can the following lines of code at the end of the functions.php file for your theme. It can be accessed by going to the WordPress admin page. You can then go to Appearance > Editor and click on the functions.php template on the right.


ini_set( 'upload_max_size' , '32M' );
ini_set( 'post_max_size', '32M');
ini_set( 'max_execution_time', '180' );
ini_set( 'max_input_time', '180' );


There you have it. You can now upload larger images or documents without getting errors again as long as you remain within the increased limits.

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.

Available under:
Articles, Guides, Tips, Tutorials