How to Change or Increase the WordPress Upload Limits

How to increase the wordpress upload limits

In this post, today, I will share my personally tried methods while changing the upload limits in WordPress.

Why multiple methods to change the WordPress upload limits

There are various factors. Few of them are:

How did the developer developed or coded the website?

How did the developer plan to manage certain functions in your website

Most importantly, the way your host handles the WordPress installations.

When we need to Change WordPress Upload Limits

In your Website on WordPress, your aim is to win the race in content marketing.

You use videos, images and sometimes audio files. When you upload any kind of media files you may encounter with an error.

One error message which I found various times on few sites is: “The uploaded file exceeds the upload_max_filesize directive in php.ini.” But, the exact phrase of the error may change per site, but it reads like ‘your upload is not successful due to the permitted upload file size is lessor than the size of the file you trying to upload.

But, you would not like to Ctrl+Shift+Del the idea of uploading the file in first option. Right?

So when you get such errors while uploading the files in wordpress website, you shall change the upload limits on your wordpress website.

Methods to change the WordPress Upload Limits in Linux

Unfortunately, there is not one single option or method which fits to every website. Maximum number of times the method of changing the upload limits varies basis on the server configuratoin.

The method which been followed by many of our clients is like to Skype the screenshot of the error to its Developer in Business Labs. But this maynot be a case with everyone out there. You may need certain (easy to follow) tricks which you can yourself do it.

This article will take you through few of the step which will solve your problem of changing the upload limits.

Most of the below steps may require you to access your site via FTP or via Cpanel. If you are not familiar with how FTP works, I’d recommend you to go through this guide to installing WordPress by Kevin Muldoon’s. It has a section on accessing your site via FTP.

Setting up a PHP Info File

Before you even start, it is advisable to get some details about the PHP configured on your site.

PHP has a easy function to assist us do this. Create a new file in notepad and add this line of code to it:

<?php phpinfo(); ?>

Save the file with the name “info.php”.

Now, move this file in the root of your server where wordpress in installed.

Next, visit “http://domain.com/info.php”. (Replace “domain.com” with the actual URL of your site.

This will give you a full list of details about your PHP configuration. (as shown in this screenshot)

PHP info file

Pay special attention to the version of PHP you are running

The most important part here is the PHP version you are using. This will be shown in block letters at the top, for an instance “PHP Version 5.4.16”.

There are further three important settings within the PHP info file which is relevant to your upload limit. You can search in the file to see what is the current limits set.

memory_limit – This defines how much memory is allocated to your PHP. You will simply need to ensure that this number is as high or higher than the upload limit you want to set.

post_max_size – This defines the maximum size that is handled in a POST request. We will need to set this to our new upload limit.

upload_max_filesize – This defines the maximum size for file uploads. This will also be set to our new upload limit.

Now that we have a little bit of info about our PHP set-up, we can try a few different methods for increasing our file size limit.

First Step in Changing the WordPress Upload Limit

Editing PHP.ini

The php.ini file contains all of your PHP’s configuration details. Editing this file will let you change the values you saw on your PHP info page.

Your php.ini file will be visible to you in your wordpress installation folder, inside config or etc folders. But this depends on your webhost too. Since this article is meant for someone who understand how to access the server. But in anycase, you ar enot able to find the file in your server, I suggest you to either contact your webhost or contact our experts in businesslabs via the contact form available at the end of this post.

Now, lets begin.

First – Take take the backup of this php.ini file.

Second – Change the upload limits.

For example, I increased the upload limit to 64 MB. You can even go higher than this, but it is not recommended to go higher than 128 MB.

A snippet from php.ini

The PHP.ini file

Now, find the “memory_limit” value, and change this to 64M (unless this is already set to something higher).

Next, find the the “post_max_size” and make this to 64M.

Finally, search the “upload_max_filesize” and once again set this to 64M.

It is important that we use an “M” to define our filesize limit in megabytes, instead of the commonly used MB.

You may also want to find the “max_execution_time” variable and set it to something like 300. This will ensure that your site does not time out when uploading larger files. In the end, your values will look like this:

memory_limit = 64M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300

The above is a snippet code which you finally need to set.

Once you are done, save your file.

You may need to restart your server or refresh the website. Contact your webhost or our experts in case you find any troubles.

Second Step to Change the Upload Limit

Uploading your own PHP.ini

In case you are not able to find a php.ini file in your server, you can ask the same to your host. At times, host donot provide too. If that is the case, you can create you own file, open it up in your text editor and paste the below code:

memory_limit = 64M
upload_max_filesize = 64M
post_max_size = 64M
file_uploads = On
max_execution_time = 300

You can see in the above sample code, I am setting the upload limit to 64MB, but you can change this value to whatever you want. Finally save the file as “php.ini” in your root of the wordpress installation.

Another method to change the Maximum Upload Limits

Using .user.ini

This method works only if you are using a version of PHP 5. Otherwise, you can skip this section.

Create a new file, and this time call it “.user.ini”. In this file, paste the following code:

upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 64M
max_execution_time = 300

You can change the value of 64M to match your new desired upload limit. Save this file in the root of your server.

One more method to increase the maximum upload limits

Trying .htaccess

To access your htaccess file, go to the root directory of your WordPress installation. If you using FTP than enable your FTP client to view hidden files.

First take the backup of this file.

Now open up the file labeled “.htaccess” to edit. At the last of the file, paste in this code:

php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300

Now Save this file. Visit your site, and look for any errors. In case you find any errors, just replace back your backedup file.

If now errors show up, simply try uploading the media files you initially tried when you was shown the maximum upload file size restrictions.

Editing the WordPress Config File – another method to increase the max upload file size

If nothing works well, this is one more trick you should try.

Here we will edit the wordpress files directly.

First, search for the file named “wp-config.php” in your root.The first step is to FTP into your server, and drag your “wp-config.php” file, located in the root directory, so that you can edit locally. Open up the file, and at towards the bottom

Then, take its backup before editing.The first step is to FTP into your server, and drag your “wp-config.php” file, located in the root directory, so that you can edit locally. Open up the file, and at towards the bottom

Next, open the file and add the below code at the bottom:

define(‘WP_MEMORY_LIMIT’, ’64M’);

Then save this file on the server.

Now, get inside the active theme folder which you can find inside “wp-content”.

Search “Functions.php” file and open it up for editing. (Don’t forget to take its backup as well.)

At the top of the “functions.php” file add the following code:

@ini_set( ‘upload_max_size’ , ’64M’ );
@ini_set( ‘post_max_size’, ’64M’);
@ini_set( ‘max_execution_time’, ‘300’ );

Now save the file in your server.

Contacting your Web Host

If you are someone not willing to do the hard work or take risk of code, simply contact the web host. In case your webhost donot help you out, simply search for better web host.

Contact Experts in Business Labs

Unfortunately, there are quite a few things that you may need to try before you can increase the upload limit on your WordPress install. I can’t guarantee that they will work, but hopefully one of these will. If nothing works out, don’t hesitate to reach out to our experts at Business Labs for help.

Reach our Experts for any Help

5 + 15 =

Leave a Reply

Your email address will not be published. Required fields are marked *