The WordPress user interface is great for handling most of the site maintenance. The simple media uploader is one of the many advanced tools it provides its users. The default media uploader makes uploading files to WordPress very easy.
The media uploader follows some default settings that control file uploading to WordPress. The maximum file upload size depends on your WordPress settings as well as your hosting plan.
In some cases, the default WordPress settings for maximum file upload size could be as little as 2MB. This is fine as long as you wish to upload only text files or images that are below the file size restriction. But if you want to upload a file bigger than this, WordPress will immediately throw an error and the file uploading will fail.
You might want to upload some videos, images or other files at some point that may exceed the default file size. In order to upload these bigger files, you need to know how to increase the maximum limit of file upload size.
There are few ways to solve this problem. We are going to talk about them one at a time. But first, let me focus on some basics of settings customization.
Checking the Default Settings
First of all, we are going to look at how to check the default settings of our PHP installation. We can find out the default settings of our current PHP installation by creating a simple php file.
Go to your home directory and create a file called “phpinfo.php”. You may name it anything you want but I am going to name it this way in this tutorial. Now paste in the following line of code inside this file:
This file needs to placed inside your main directory. For example, if your main directory is public_html, put this file inside the public_html folder. Now open this file using your browser. If your domain is domainname.com, go to http://domainname.com/phpinfo.php.
You will see a page containing all configuration settings of your php installation. Find out the value for upload_max_filesize. This is what controls the maximum size of file upload. You cannot change this default value from here, however.
Find out the value of “Loaded Configuration File” settings. This is the path of your php.ini file. We need to know this path in order to access and edit this file.
Editing the php.ini File
Go to the directory where the php.ini file is located and open it with your file editor. If you are using your localhost, you can easily access this file. Open this file and find the line that says “upload_max_filesize = ”. Set your desired value here and save the file.
For example, if you want your maximum file upload size to be 300MB, it should look like the following line:
upload_max_filesize = 300M
But if you are on a shared host, you probably will not have access to the php.ini file. In this case you need to create a php.ini file on your home directory. Then simply paste in the following code inside this file and save it.
upload_max_filesize = 300M
Try uploading a new file now using your WordPress media uploader and the new settings should take effect.
Editing htaccess File
In your root directory, there should be a .htaccess file. Open it using your editor and set the value of upload_max_filesize like this:
php_value upload_max_filesize 300M
This will reset your default maximum file upload size.
Editing Theme Functions File
There is another way to increase your maximum file upload size in WordPress. This is done by editing the functions.php file of your theme. Add the following lines to your functions file:
@ini_set( 'upload_max_size' , '300M' ); @ini_set( 'post_max_size', '128M'); @ini_set( 'max_execution_time', '300' );
It does not always work, but you should try it if the other two methods do not work.
These are the common ways of increasing maximum file upload size in WordPress. If you have any further questions, please feel free to comment below.