How to fix file upload errors in WordPress

Have you ever tried to upload a file on wordpress only to see the following error message:

The uploaded file exceeds the upload_max_filesize directive in php.ini

WordPress has certain size limits depending on the platform that’s hosting your WordPress site. In turn, the PHP memory that is designated for plugins, themes and scripts also have a certain cap.

Like most error messages that flash up on computer screens and scare the living daylights out of everyday users the fix to the problem is relatively easy and there are several options to resolve this that focus on upload_max_filesize.

Option 1: edit .htaccess

To begin with navigate to the root directory of WordPress. If you are using a hosted platform then you should be able to navigate to the root directory using a file manager or ftp. If, like me you are self hosting, then you will need to edit the .htaccess file via CLI

Add the following line at the bottom of the .htaccess file:

php_value upload_max_filesize 256M

Save the file and leave it for a few minutes then try uploading the file again. If you are self hosting then you can simply restart the server to implement the changes. If the problem persists you could try increasing the limits on the following directives.

php_value post_max_size 256M
php_value memory_limit 512M
php_value max_input_time 180
php_value max_execution_time 180

If these changes do not resolve the issue then consider option 2.

Option 2: Edit wp-config.php

This file is located in the main WordPress directory. Open the file and add the following directive before the /* That’s all, stop editing! Happy Blogging. */

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

Option 3: Update the php.ini file

If you look closely at the upload_max_filesize error, you may have worked out that it has something to do with the php.ini which is a file that sets the php limit related variables. In most cases if you are using a hosting service, these limits will be set to their maximum values for convenience therefore you won’t be able to change these settings. However if you are self hosting then you should be able to edit this.

You will have to navigate to the php.ini file location which will vary depending on your setup. In my case the php.ini file is located at:


Open the file and look for the upload_max_filesize directive and increase it. You may also want to consider increasing the limits on some other directives to see if they will resolve the issue.

upload_max_filesize = 256MB
post_max_size = 256M
memory_limit = 512M
max_execution_time = 180

Option 4: Contact Support

If all of the options outlined above do not resolve the issue and you are on a hosted platform then you should consider contacting your hosts customer support. Do tell them what steps you have taken to try and resolve the issue. You may also want to take a look at the current upload limit which can be found via Media/Add New as illustrated below.

Navigate to Media/Add New to view the maximum file upload limit


In this tutorial we have looked at 4 different options that can be taken to resolve the “The uploaded file exceeds the upload_max_filesize directive in php.ini”