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. Installing WordPress is a fairly easy task and it only takes a few minutes. After installing WordPress, you may want to change the default theme and install a new one, install some WordPress plugins, create new posts and upload image files, etc. and this is when you may receive the following error: The uploaded file exceeds the upload_max_filesize directive in php.ini. In this tutorial we’ll show you, how to fix The uploaded file exceeds the upload_max_filesize directive in php.ini.
There are four simple ways you can fix The uploaded file exceeds the upload_max_filesize directive in php.ini error in WordPress:
Table of Contents
1. 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.
2. 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
3. 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’ );
4. 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
Once you locate the main PHP configuration file, edit it and add or modify the following line:
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.
- Create a local php.ini configuration file in the document root of the WordPress installation, ‘add upload_max_filesize = 100M’ to it, save the file thus override main php.ini configuration settings.
Again, you need to restart your web server for the changes to take effect.
You should be able to install new WordPress theme, plugins, and upload image files now and the error: The uploaded file exceeds the upload_max_filesize directive in php.ini should be resolved.
Of course, you don’t have to fix The uploaded file exceeds the upload_max_filesize directive in php.ini error by yourself, if you use our WordPress Hosting services, in which case you can simply ask our expert Linux admins to change the upload_max_filesize PHP setting for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post on how to fix The uploaded file exceeds the upload_max_filesize directive in php.ini, please share it with your friends on the social networks using the buttons below or simply leave a comment in the comments section. Thanks.
I am still getting this error even though , max_upload_filesize is 10GB in the wordpress media gallery admin.
Please help me out.
Did you check your web server log files?
Thank you very much! I am just a beginner and it is very comforting when I can find answers to at least some of my many questions!
Thank you! Thank you! Thank you! Thank you!)))))) I was with this problem for month and you really helped me)))
I get an internal error message whenever i edit the .htaccess file. What I’m i doing wrong. Below is whats in the .htaccess file when i open it
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Where i’m I adding the additional line of code. Please help
Hi Tolu,
Did you check the log files for more details about the problem?
if using localhost..just simply extract file..and place folder inside theme folder
1ST ONE IS WORKING!!
But after updating .htaccess i can upload a file one but after the code pasted into this file get disappears and i need to add those code again. please tell me a permanent fix for this problem?