09 Jul How to Increase the Maximum File Upload Limit in WordPress
With WordPress, anyone can create a website that is full of rich content including images, videos or music files. With so many features supported, it is always users who have to tweak their setups so that it works best for you.
Recently, I encountered a problem that many of us find irritating, the maximum file upload limit in WordPress. We all have different requirements and that lead to different need in a file upload.
WordPress, by default, have tough restrictions on the file upload limit. To add media, we know where to go, we probably do not take the limit into consideration, until one of our file uploads fails with an error message
The file upload size exceeds the upload_max_filesize directive in php.ini
The above error message can differ according to the version of WordPress using it. And, for the normal WordPress users, the above message can be terrifying and downright confusing.
Don’t worry, as today, we will discuss, How to Increase the Maximum File Upload Limit in WordPress.
The methods that we will discuss require an intermediate level of understanding of the WordPress platform, and that’s why we urge the reader to be sure of what they are doing. If you are not sure about your skill-level, it is always better to take help of someone with experience.
If you have decided to follow the article yourself, I urge you to backup your website including the database before proceeding. A slight mistake can wipe your Website, and we do not want you to regret later. The backup methodology should be followed in almost all the cases during core change or server settings.
How to Increase the Maximum File Upload Limit in WordPress
So, who holds the key? There are many ways you can change the maximum file upload limit. If one does not work, you can try out the other one and so on. The files are related to server side functioning as server stores those media files.
Many the web hosting companies have different upload limit, and if everything fails, you might need to buzz up your customer support so that they can fix it for you.
How to Know the maximum file upload limit and other associated information
But before we proceed, we need to get information about the current WordPress installation and server settings. To do so, we have to setup the PHP info file.
The PHP file can be added to your WordPress installation. The file should contain only one line of code, which is as follows.
<?php phpinfo(); ?>
After putting the above line of code, you can save the file as you please. For the sake of familiarity and accessibility, I decided to name it as “serverinfo.php”.
Upload the file to your hosting using the FTP or the cPanel. Anyone of them will work. Next step is open the file by following the below URL.
With the server details shown, you can ignore most of the information show here. The most important information that you need take note is which version of PHP your server is using. It can be either PHP 4 or PHP 5. In the above image, PHP 5.4.16 is being used.
Before, we move forward, we need to understand three basic terms related to php.ini. They are as follows.
- memory_limit: WordPress uses the memory_limit parameter in php.ini to allocate the memory that can be accessed by the installation. You need to make sure that the value is set more than the file upload limit that you will use.
- post_max_size: Post requests are done when there is a communication between the server and the client. To make sure that the media file transfer goes smoothly, you need to set the value to the new upload limit.
- upload_max_filesize: The last parameter we need to take care of is the upload_max_filesize. It takes care of the maximum file upload size. We also need to set it to the new upload limit.
Method 1: Editing the php.ini file
1. Find the php.ini file in your WordPress root directory.
2. If there is no PHP.ini file, you can create and upload it to the root directory.
3. Use the following code in the php.ini file.
upload_max_filesize = 96M
post_max_size = 96M
max_execution_time = 300
Here, M denoted MB, So, 96 M denoted 96 MB. Change the value according to your requirements.
Note: The allowed file_upload size ranges from 0 to 128 M, so choose accordingly.
Method 2: Editing the Theme files
Theme files are easily accessible and that’s why there is an easy way to get the upload_limit work for you.
You need to update the theme function’s file. Inside the functions file, copy-paste the below code for setting up the new upload limit.
@ini_set( ‘upload_max_size’ , ’96M’ );
@ini_set( ‘post_max_size’, ’96M’);
@ini_set( ‘max_execution_time’, ‘300’ );
The @ini_set functions make new changes to the php.ini file. Cool, right? Indeed, it is.
Method 3: Using the power of .htaccess
.htaccess file holds a lot of customization power for the server. You can also use it modify the upload limit.
Open and paste the below code to make it work. The .htaccess file can be found in the root directory of your WordPress installation.
php_value upload_max_filesize 96M
php_value post_max_size 96M
php_value max_execution_time 300
php_value max_input_time 300
Method 4: Asking your Web Hosting Company to do it for you
Even though the above methods are easy to follow and do, many web hosting companies do not allow any change in the file upload limit.
So, you need to contact the hosting support and ask them to do it for you. In most of the cases, there won’t be any problem, until and unless there is some stringent company policy on the file upload limit.
I found it deeply satisfying to help you increase the file upload limit. Not every one of us has similar requirements and many websites use complicated media such as videos, audio, which can be of several megabytes size.
The tutorial is not at the beginner level, but I am sure that they can follow and do the changes themselves. If you’re still confused about anything, you can comment below and ask me any question regarding the topic.
Also, share the article as much as you can!