The uploaded file exceeds the upload_max_filesize directive in php.ini


How to Fix ‘The uploaded file exceeds the upload_max_filesize directive in php.ini’ in WordPress

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

There is no need to panic, because the solution of  The uploaded file exceeds the upload_max_filesize directive in php.ini is quick and easy.

There are four simple ways you can fix this problem:

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

    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
    Get optimized, fully managed WordPress hosting from us and we’ll configure and fix your WordPress for free
  2. 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' );
  3. 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.

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

That is it. 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 do any of this if you use one of our Linux VPS 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 please share it with your friends on the social networks using the buttons below or simply leave a comment in the comments section. Thanks.

 

Tutorials
Install WordPress using SVN on a CentOS 7 VPS
Tips and Tricks
First Steps After Getting a CentOS VPS
Tutorials
Install WordPress with HHVM, Nginx and MariaDB on an Ubuntu 12.04 LTS
  • Jyoti Rai

    Jyoti RaiJyoti Rai

    Author Reply

    I am still getting this error even though , max_upload_filesize is 10GB in the wordpress media gallery admin.
    Please help me out.


    • admin

      adminadmin

      Author Reply

      Did you check your web server log files?


  • Kai

    KaiKai

    Author Reply

    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!


 
Free Migration to RoseHosting. Award Winning Linux VPS Hosting with Fully Managed Support. Coupon RHBLOG50 for 50% offOrder Now
+