[WordPress] How to increase the maximum upload file size
In this article, I will explain how to increase the maximum upload file size. In many cases, the default maximum upload file size is 2MB, which is a little bit small. We often want to upload a file that is larger than 2MB, and in that case, the maximum upload file size will be an obstacle. Once you read this article, you’ll be able to configure the value of “maximum upload file size” as you like, and this will enable you to upload a large file to your WordPress.
Table of Contents
An error occurs when uploading an overly large file
If we upload a file that is larger than the maximum size, an error occurs and we can’t upload the file. For example, go to “Media”→”Add New”, and we can see how much the maximum upload file size is. In many cases, including my case, the default value is 2MB.
Once we try to upload a file that is larger than 2MB, we’ll get an error shown in the image below.
To fix this problem and upload the file, we need to reconfigure the maximum upload file size. Let’s see how to do this reconfiguration.
How to increase the maximum upload file size
There are several ways to change the value of the maximum upload file size. For example, change the “php.ini” file, change the “function.php” file, or some WordPress hosting services allows you to change this value from the control panel. But here I’ll explain a method that uses the “.htaccess” file. The steps below show how to do this.
Step1: Go to the root directory of the WordPress
In my case, it was “/var/www/html”. If you use a cloud server and can’t access the server, skip this step and follow the steps below. After you make the .htaccess file on your local PC, then send it to the root directory of WordPress in the cloud server. I think you can send the file using FTP or from the control panel of the server hosting service.
$ cd /var/www/html/
Step2: Create the “.htaccess” file if there isn’t
If there isn’t a file named “.htaccess” in that directory, create the file in the current directory. If there’s already this file, you can skip this step.
$ touch .htaccess
Step3: Modify “.htaccess” file
Now edit the .htaccess file and add the lines below. Note that we need to add the lines at the bottom of the file, otherwise the configuration can be deleted when the WordPress is updated. Lines that start from “#” are comments
# the maximum size of memory usage php_value memory_limit 20M # the maximum size of total POST data php_value post_max_size 20M # the maximum size of a single uploaded file php_value upload_max_filesize 20M
Here I set the maximum size to be 20MB, but you can change this value as you like. If you want to upload a larger file, you can set a larger value, such as 50MB.
Check if the configuration is applied
Now the configuration is done, so let’s check if the configuration is applied properly. Go to “Media”→”Add New”, and you will see the maximum upload file size.
Congragulations! Now the maximum upload file size is increased!
- The default maximum upload file size is 2MB, and we need to change this value if we want to upload a large file.
- To change this value, we can a make .htaccess file and locate the file to the appropriate directory.