How to Increase the Maximum File Upload Size in WordPress

Running a WordPress site, you may sometimes get “exceeds the maximum upload size for this site” error while uploading a file or image. This usually happens when you exceed the maximum file upload size. In that case, you need to increase the maximum file upload size in WordPress.

It’s important to understand that this is usually not a WordPress issue. Yes, by default, the WordPress hosting service provider keeps the maximum file upload size between 2-5MB and when you try uploading files more than defined upload size.

Well, we think that’s fair enough, but nowadays a default upload of 2 or 5 MB just doesn’t cut it, let’s see how we can go about increasing it.

How to Increase the Maximum File Upload Size in WordPress?

There are a few methods that you can apply to fix this issue. However, we’ll only start with the easiest ones, then move on to changing the server settings yourself, as there are a number of options there as well.

  1. Create or Edit PHP.INI file

We assume that you know your website’s PHP.ini contains the PHP configuration for your server. This can be easily located in the root directory of your server.

All you need to do is access your WordPress site’s root folder by using FTP client or cPanel and place following code. But, if you are on a shared host, then probably you will not find a php.ini file in your directory. In that case, you need to create a file called php.ini, place the code and upload it to the root folder.

upload_max_filesize = 64M

post_max_size = 64M

max_execution_time = 300

You may increase or decrease the value as per your requirement.

2. Create Or Modify .user.ini Files

If the above method didn’t work for you, it could be that your host has the global settings locked down and instead have it configured to utilize .user.ini files. To edit and change the value in your .user.ini file, login to your site via FTP, and go to your site’s root directory. Now, open or create a .user.ini file and then paste the following code.

upload_max_filesize = 64M

post_max_size = 64M

memory_limit = 64M

3. Theme Functions File/WP-Config file

If the above method doesn’t work for you then you have another basic method to use. For this, you need to access either your theme’s functions.php file or WP-Config file (located in WordPress directory) and place the following code.

@ini_set( 'upload_max_size' , '64M' );

@ini_set( 'post_max_size', '64M');

@ini_set( 'max_execution_time', '300' );

We believe, this method should work for you. If not, then move to the next method.

  1. Via .htaccess

The .htaccess file is a special hidden file that contains various settings you can use to modify the server behavior, right down to a directory specific level. If the php.ini method above didn’t work, we suggest you try this next. Simply edit the .htaccess file in your WordPress site’s root folder and add the following code.

php_valueupload_max_filesize 64M

php_valuepost_max_size 64M

php_valuemax_execution_time 300

php_valuemax_input_time 300

If you get an “internal server error” message with the method above it is most likely your server is running PHP in “CGI mode,” which means you can’t use the above commands in your .htaccess file. In that case, you would have to contact your web hosting provider to increase the limit for you.

You can consider reading, how to speed up WordPress website performance easily.

We believe, this article has helped you to increase the maximum file upload size for your WordPress website. If you liked our article, then please do share this on your social media and spread the word. This will help us to reach out to more users like you.