Introduction

Though Wordpress is highly stable, it is not without errors

The Uploaded File Exceeds the upload_max_filesize Directive in php.ini. Error in WordPress error occurs when a user uploads very large files (or themes).

This 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 the error.

how to fix the uploaded file exceeds the upload_max_filesize directive in php.ini. error in wordpress

Prerequisites

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

3 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.

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 will change the server-side limit on the size of the file you’re allowed to upload.

3. Save the changes and exit.

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

cd /path/to/wordpress
sudo nano .htaccess

This will change to your WordPress directory, then open the .htaccess file in the Nano text editor. You can make and save your changes there.

2: Editing wp-config.php file

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

1. Find the wp-config.php file – right click, then left-click the edit option. 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, then try your upload again.

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.phps

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.

1. Log into your server hosting WordPress.

2. Open a terminal window/command line, and enter the following:

cd /etc/php/7.0/cli

The command prompt should change to reflect that you’re in that directory.

Note: If you’re running a different version of PHP, 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. 256 is recommended above, but you can use any value you like.

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 error should be resolved.

Conclusion

In this tutorial, we covered three different ways to Increase the maximum file upload size in WordPress. We hope this guide fixed and eliminated the error.