HOW TO INCREASE THE MAX FILE UPLOAD SIZE IN WORDPRESS WITH “.HTACCESS”

There are two ways to install a theme in WordPress. The first is probably the most common way, in the dashboard you click Appearance/ Themes, then find your theme and click install and activate. You know the drill…

But there is a second option. You can install the theme from your local hard drive instead. It is usually the option if you buy the plugin from any of the marketplaces for professional themes or maybe directly from the developer.

The problem is often that the file size of the theme is bigger than the default upload limit of WordPress. But it’s easy to change. There are several ways to do it, I have found that this one works well for me.

To change the max file upload size:

1. Open .htaccess (in the root of your site folder)

2. In the bottom of the file, add these lines:

php_value upload_max_filesize 5M (where 5 is the size you want)
php_value post_max_size 5M

3. If you get a timeout, increase it by adding these lines:

php_value max_execution_time 300 (where 300 is in seconds)
php_value max_input_time 300

How to find out if the limit is too small

Check what the WordPress limit is set to

In the dashboard, go to Media/ Add New, where you will find the Maximum upload file size.

Check the size of the template zip-file

Open the folder where you have stored the template. Look at the size to the right. Now, this is in kilobytes (kB), whereas the WordPress limit is in megabytes (MB).

Compare the sizes

To convert the file size to MB you simply divide:
4097/ 1024 = 4.0010

Now, the important thing is that we see that the result is slightly bigger than 4, so we have to set the size to at least 5 MB.

Why 1024?
Do you wonder why we divide with 1024 and not 1000? It’s because computers are based on the binary system. Read about it here: https://pc.net/helpcenter/answers/why_1024_bytes

Change the .htaccess file

File location

The file is located in the root folder of the site.

If you are using WAMP, it could look like this:
C:\wamp64\www\MySite\.htaccess

It is of course similar if you change it on your web host through FTP.

The official documentation of the .htaccess file is found here:
https://httpd.apache.org/docs/2.4/howto/htaccess.html

Edit the file size limit

Simply open the file in a text editor, like Notepad on Windows or TextEdit on Mac.
Go to the bottom of the file and add these lines:

php_value upload_max_filesize 5M
php_value post_max_size 5M

Edit timeout

Bigger files take longer time to upload. And if you are uploading to your web host, and not to your local WAMP installation, the upload speed can be too slow, and the server might cut you off because you exceeded the timeout limit. Now, there is a configuration for this too.

Add these lines at the bottom of the .htaccess file.

php_value max_execution_time 300
php_value max_input_time 300

The value is in seconds. You just have to try a value and see if it was enough.

And for some reason, I had to add an empty line after the “# END WorrdPress” line, or the system would give me an error message. Haven’t figured out why.

— Cheers!

Like it? Share it!