Linux Software

The uploaded file exceeds the upload_max_filesize directive in php.ini

The uploaded file exceeds the upload_max_filesize directive in php.ini, is a common WordPress error when installing new themes, plugins, uploading new images or creating new posts.

I have moved hosts and been having problems with getting all the plugins working and updating.

Increase maximum upload file size via .htaccess

Edit the .htaccess file located in the document root directory of the WordPress installation.
Locate the .htaccess file, and edit it using your favorite editor (vi,nano,vim etc.), and add or modify the following line:

php_value upload_max_filesize 100M

Replace ‘100’ with the maximum upload file size (in megabytes) that you want to set on your WordPress installation.

Adjust other PHP configuration settings

You may also want to adjust some other PHP settings, like:
– memory_limit (maximum amount of memory a script may consume);
– post_max_size (the maximum size for all POST body data);
– max_execution_time (the maximum time in seconds a script is allowed to run before it is terminated by the parser);
– max_input_time (the maximum time in seconds a script is allowed to parse input data, like POST and GET).
If so, add or modify the following lines too:

php_value memory_limit 256M
php_value post_max_size 32M
php_value max_execution_time 600
php_value max_input_time 900

Modify the ‘functions.php’ or  ‘wp-config.php’ file

Edit the ‘functions.php’ file located in the active theme directory (wp-content/themes/), or the ‘wp-config.php’ file located in the document root directory of the WordPress installation.
Add the following line to the wp-config.php file:

@ini_set( ‘upload_max_size’ , ‘100M’ );

Modify Main PHP File

Edit the main PHP configuration file. Use the following command to locate the main PHP configuration file on your server, e.g.:

# php -i | grep -i php.ini
Configuration File (php.ini) Path => /etc/php/7.0/cli
Loaded Configuration File => /etc/php/7.0/cli/php.ini

This you might need your host to do for you.

upload_max_filesize = 100M

It is a good idea to modify these settings too:

memory_limit = 256M
post_max_size = 32M
file_uploads = On
max_execution_time = 600
max_input_time = 900

Do not forget to restart your web server for the changes to take effect.

(Visited 83 times, 1 visits today)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.