WordPress is a highly stable platform. However, errors may occur in some cases.

One of them is the uploaded file exceeds the upload_max_filesize directive in php.ini. error. This error occurs in WordPress when a user uploads large files, themes, or images. The issue is the result of a server-side setting that limits file sizes.

This guide will walk you through adjusting the appropriate parameters to resolve the file size error.

How to fix upload file size error in WordPress


  • An existing installation of MySQL
  • Access to a command line or terminal
  • A text editor
  • If you are working from a client system, a file manager (or cPanel) is helpful

Three Options to Fix Wordpress Uploaded File Exceeds Error

1: Edit the .htaccess File

1. Open cPanel, then launch the file manager. You may need to click Settings in the upper-right corner and check the box to show hidden files.

cPanel settings to show hidden files

2. Right-click the .htaccess file, then click edit.

Look for a line that says php_value upload_max_filesize and edit it to look as follows:

php_value_upload_max_filesize 256M

This instruction changes the server-side limit on the size of the file you’re allowed to upload.

3. Save the changes and exit.

Optionally, if you’re logged in to the server that hosts your WordPress site, you can perform the same steps from a Linux command line. Enter the following:

cd /path/to/wordpress

and then:

sudo nano .htaccess

The first command changes from the current directory to your WordPress directory, and then opens the .htaccess file in the Nano text editor. You can make the same change here.

2: Editing wp-config.php File

Another method to change the limits on the PHP file size is to edit the wp-config.php file directly. Like the .htaccess file, it’s located in the public_html folder. However, this time it’s not a hidden file.

1. Find the wp-config.php file. Right-click the file, and select the edit option.

edit wp-config file window

Scroll down near the bottom and look for the following comment line:

/* That’s all, stop editing! Happy blogging. */

2. Just above that line, add the following code:

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

3. Save the file and exit. Try to upload your file again, the error should not occur.

Note: As with the previous command, this can be done from a command line if you’re working on the server that hosts the WordPress site.

Browse to the file location and open it for editing as follows:

cd /path/to/wordpress
sudo nano wp-config.php

Make the same edits as above, then save the file and exit.

3: Edit php.ini File

You may have guessed from the text of the error message that this is a problem with PHP. The php.ini file is a configuration file for PHP variables.

To edit the php.ini file:

1. Log into your server hosting WordPress.

2. Open a command-line interface, and enter the following:

cd /etc/php/7.0/cli

The command-line interface should change the path to reflect that you’re in that directory.

If you’re running a different version of PHP, make sure to replace 7.0 with your version.

3. Next, enter the command:

sudo nano php.ini

The php.ini file should open in a text editor.

4. Locate the line:

php_value upload_max_filesize 100M

Replace 100M with a higher value in megabytes. We recommended 256, but you can use any amount you want.

While you’re here, there are some other settings you can adjust:

  • memory_limit 256M – Sets the max amount of memory a script can use.
  • post_max_size 32M – Sets the max size for the total of the POST body data.
  • max_execution_time 600 – Max time, in seconds, that a script is allowed to run.
  • max_input_time 900 – Max time, in seconds, that a script is allowed to parse input data.

5. Save the file and exit.

Test your file upload in WordPress – the issue with file size should be resolved.


Now you know how to fix the error “The uploaded file exceeds the upload_max_filesize directive in php.ini.” in WordPress. This tutorial covered three different ways to increase the maximum file upload size. You can choose the method you prefer, the outcome is the same.