When buying products or services on our site, we often receive affiliate commissions that support our efforts. Learn More

How to Fix The Uploaded File Exceeds the upload_max_filesize Directive in php.ini WordPress Error

Upload Max Filesize

ERROR: UPLOADED FILE EXCEEDS THE UPLOAD_MAX_FILESIZE DIRECTIVE IN PHP.INI

Uploading large files, namely themes, plugins, images, videos, etc. in WordPress, can sometimes cause an error with the upload file size limits – this is caused by the default configuration in your server’s PHP settings.  To fix this error, it is necessary to increase the max file size upload limit in the PHP settings.

Upload limits are initially capped by your web host in order to conserve the server’s data reserves.  It is common to see this cap set at 2MB to prevent users from uploading excessively large files.  Uploading any type of file larger than this limit will throw this error:

The uploaded file exceeds the upload_max_filesize directive in php.ini.

 

HOW TO CHECK YOUR UPLOAD MAX FILESIZE LIMIT AND PHP SETTINGS

If you’ve come across this error, here are 2 different ways to check the current max upload file size limit for your WordPress website.

  • For a basic view go to Media >> Add New from your WordPress admin dashboard.check max upload limit from WordPress
  • For a detailed view on all PHP settings for your server you need to access the php.info page.
    • 1. Open up any web browser and type: yourwebsiteurl.com/info.php or yourwebsiteurl.com/phpinfo.php in the URL address bar.
    • 2. Replace yourwebsiteurl with your actual website URL.  The URL will be different depending on how the file was named – typically info.php or phpinfo.php so try both.
    • 3. Use the function Ctrl + F to search for upload_max_filesize.  You will need to change this value to override the upload error.info-php

 

HOW TO CREATE INFO.PHP PAGE IF FILE IS NOT AVAILABLE

If you get a 404 error when navigating to “yourwebsiteurl.com/info.php” or “yourwebsiteurl.com/phpinfo.php” this means that the PHP file does not exist but you can still create one.  To create an info.php file:

      • 1. Log into your web host cPanel and open File Manager.
      • 2. Once in File Manager, click public_html. This is where info.php file will be created.
      • 3. From the top menu, click New File or + File, name the file info.php and create it. This file can also be named phpinfo.php or anything else you want but it’s better to use these common names.create-info-php
      • 4. Locate the info.php file on the right and click Edit from the top menu. When prompted to select the character encoding, choose utf-8 (this should be the default).
      • 5. Enter this code below and click Save Changes.


    <?php
    phpinfo();
    ?>

     

     

    SOLVED: UPLOADED FILE EXCEEDS THE UPLOAD_MAX_FILESIZE DIRECTIVE IN PHP.INI

    There are several different ways to increase the max file size upload limit in WordPress.  The traditional ways require editing code in the php.ini, .htaccess or wp-config files but there are also simpler methods – without having to write any code in the server files.

    4 different ways to increase the max file size upload limit:

    • Method 1 – Edit settings in PHP Selector (cPanel)
    • Method 2 – Edit settings in MultiPHP INI Editor (cPanel)
    • Method 3 – Update php.ini file (FTP or File Manager)
    • Method 4 – Edit .htaccess file (FTP or File Manager)
    • Method 5 – Edit wp-config.php file (FTP or File Manager)

    Note: Whichever method you use, to prevent any errors it’s important to follow these rules:

      • post_max_size should be larger than upload_max_filesize
      • memory_limit should be larger than post_max_size

     

    METHOD 1 – EDIT SETTINGS IN PHP SELECTOR FROM CPANEL (NO CODE REQUIRED)

    • 1. From your web host cPanel, search PHP from the top search bar and open Select PHP Version.php selector
    • 2. Click Switch to PHP options.php options
    • 3. From here you can increase the upload_max_filesize from the drop down menu.upload max filesize from php selector

     

    METHOD 2 – EDIT SETTINGS IN MULTIPHP INI EDITOR FROM CPANEL (NO CODE REQUIRED)

    • 1. From your web host cPanel, search PHP from the top search bar and open MultiPHP INI Editor.multi php ini editor
    • 2. From the drop down menu, select your domain.
    • 3. Change the value for upload_max_filesize and click Apply.upload max filesize from multi php ini editor

     

    METHOD 3 – CREATE OR EDIT PHP.INI FILE VIA FTP OR FILE MANAGER

    This method requires you to access your root folder (public_html) either by using FTP or File Manager in cPanel.  If you’re on a shared web hosting plan, chances are this file cannot be accessed but you can still create and upload your own.

    • From File Manager in cPanel
    • 1. From your web host cPanel, open File Manager and go to your root folder (public_html).
    • 2. If you see the file php.ini you can edit this file.  If you don’t see this file, proceed to next step to create one.
    • 3. From the top menu, click New File or + File, name the file info.php and create it in your root folder (public_html).
    • 4. Locate the info.php file and right-click and Edit. When prompted to select the character encoding, choose utf-8 (this should be the default).
    • 5. Input the following code and click Save Changes:


    memory_limit = 256M
    upload_max_filesize = 64M
    post_max_size = 128M
    max_execution_time = 300

    • Upload using FTP
    • 1. Connect to your website’s root folder via FTP.
    • 2. If you see the file php.ini you can edit this file.  If you don’t see this file, proceed to next step to create one.
    • 3. Create a new file, name it info.php and save it in your root folder.
    • 4. Locate the info.php file and right-click and Edit.
    • 5. Input the above code and Save Changes.

     

    METHOD 4 – EDIT .HTACCESS FILE VIA FTP OR FILE MANAGER

    This method requires editing the server configuration file .htaccess via either FTP or cPanel’s File Manager.  If you don’t see it in cPanel’s File Manager, it could be hidden.  Click Setttings and Show Hidden Files from the top menu to show all files.

    • 1. Find the .htaccess file from your root folder either via FTP or cPanel’s File Manager.
    • 2. Right-click the file and select Edit.  If prompted to select the character encoding, choose utf-8 (this should be the default).
    • 3. Input the following code and click Save Changes:


    php_value memory_limit 256M
    php_value upload_max_filesize 64M
    php_value post_max_size 128M
    php_value max_execution_time 300
    php_value max_input_time 300

    METHOD 5 – EDIT WP-CONFIG.PHP FILE VIA FTP OR FILE MANAGER

    This method requires editing the primary configuration file wp-config.php via either FTP or cPanel’s File Manager.

    • 1. Find the wp-config.php file from your root folder either via FTP or cPanel’s File Manager.
    • 2. Right-click the file and select Edit.  If prompted to select the character encoding, choose utf-8 (this should be the default).
    • 3. Use Ctrl + F and search for define( ‘WP_DEBUG’, false );
    • 4. You should also be able to see /* That’s all, stop editing! Happy publishing. */ immediately after.
    • 5. In between those two lines of code input the following code and Save Changes:


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

    SUMMARY

    If everything was done correctly, the uploaded file exceeds the upload_max_filesize directive in php.ini. error in WordPress should now be fixed.  To recap, this error can be addressed in five different ways to increase upload_max_filesize :

    • Edit settings in PHP Selector
    • Edit settings in MultiPHP INI Editor
    • Update php.ini file
    • Edit .htaccess file
    • Edit wp-config.php file

    You can check your info.php page to verify that the upload_max_filesize, post_max_size and other values are now larger.  If for some reason none of these methods work, don’t forget that you can always contact your web host’s tech support.

     

You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *