Last updated - April 24, 2018
So you tried uploading that high-resolution video on your WordPress site, or that sizable plugin for that matter. And you are shown an error that reads like “AmazingVideo.mp4 exceeds the maximum file size for this site“. In PHP, the maximum file handling size is restricted to a certain limit. Hence to change or increase the size, there are few methods that you can try out.
In this article, I’ll show you how to increase maximum file upload size in WordPress.
But first, how can you see the default upload filesize of your site?
For this, go to Media > Add New from the WordPress sidebar menu.
The default file upload size for PHP is displayed in WordPress as shown in the screenshot below. This default file upload size information is stored in php.ini file(which we’ll discuss later in this article).
You might have come across several methods for doing this, but here I have listed three ideal approaches to changing the maximum file upload size.
Method 1: Adding code to .htaccess file
For this demonstration, I am using FileZilla.
Follow the below steps to update the .htaccess file –
- Open your website directory in Filezilla and locate the .htaccess file.
The Filezilla Client setup explanation is out of the scope of this article, you can refer this article for the tutorial.
The settings are as shown in the screenshot below.
Once you have found the .htaccess file, select the file and right-click to open the context menu. Click on View/Edit option.
Open the file using a text editor(probably Notepad++), and place the following code at the end of the code.
php_value upload_max_filesize 100MB php_value post_max_size 100MB php_value memory_limit 300MB
The upload_max_filesize variable describes the maximum size for file uploads. The post_max_size variable describes maximum size that will be handled in a POST request. And memory_limit describes the memory limit for PHP.
You can define the custom values of your own. But remember, the memory_limit has to be equal or greater than upload_max_filesize. Hence, make sure you enter the right value.
A sample .htaccess file is as shown in the screenshot below.
As you can see I have increased the file upload size to 100MB from the default 50MB.
Once you have saved the file and return back to your FTP Client software, you’ll be asked to upload(or overwrite) the updated file. Click Yes to proceed further.
A sample screenshot is shown below.
Now go to Media > Add New and reload the page to see the updated file upload size.
Method 2: Adding code to php.ini file
This method is the most preferred method for changing the file size and memory for your site. The best practice to update php.ini file is again using FTP Client software.
Search php.ini file in the root directory of your hosting server. This file can be located anywhere depending on your server. But generally, it is stored in /etc.
Once you have found the file, proceed with the editing process, as shown in the screenshot below.
Add the following code at the bottom of the page.
upload_max_filesize = 100M post_max_size = 100M max_execution = 300
The following screenshot shows the code added to the php.ini file.
Tip: If you want to see the default file upload size of your site, search “upload_max_filesize” in the file before adding the above code.
Save the file and upload it again to your server. Next, you need to restart the server to see the applied settings in the media upload dashboard. Without this, the file size will not be updated in the php.ini file.
Method 3: Adding code to Theme Functions
Although you can access Theme Functions (functions.php) file using FTP Client software(the process will be same as the above two methods), an easy method is using WordPress dashboard. But you would still need the Write access from the server to edit the theme functions file.
In the WordPress sidebar menu, navigate to Appearance > Editor.
Open the Theme Functions(functions.php) and paste the following code at the bottom section of the page.
ini_set ( 'upload_max_size' , '100M' ); ini_set ( 'post_max-size' , '100M' ); ini_set ( 'max_execution_time' , '300');
Following is a sample screenshot of the code added to functions.php
You can increase your file upload size using either of the three methods that I have discussed in this article, with the most recommended being method two. If any of the methods don’t work for you, contact your hosting service provider as a last resort. Although you may stumble upon some plugins that would help you with this process, I would strongly suggest not to go for it.
As you can see, with little understanding, you yourself could solve the problem. I hope this article was helpful enough to increase the maximum file upload size in your WordPress site.
Do let me know which method worked for you in the comment section. If you are still running into trouble with this topic, ask me in the comment section.
Or check our WordPress troubleshooting article to find solutions to common WordPress errors.
For other amazing articles, continue exploring LearnWoo.