Fix “The Uploaded File Exceeds the Upload_max_filesize Directive in PHP.ini” ERROR in WordPress?

If you’re running a WordPress site, you may have encountered the frustrating error message: “The uploaded file exceeds the upload_max_filesize directive in php.ini.” This error occurs when you attempt to upload a file that exceeds the allowed file size set in your server’s PHP configuration. Fortunately, there are several methods to resolve this issue. This article will guide you through different solutions, including adjusting settings in your .htaccess file, modifying the php.ini file, and using cPanel.

Why Does This Error Occur?

The error is a result of server settings that limit the size of files that can be uploaded via PHP scripts. By default, this limit may be set to a value lower than what you need for your uploads, especially for images, videos, or other large files.

Solutions to Fix the Upload Limit in WordPress

1. Increase the Upload Size in php.ini

One of the most effective ways to increase the upload limit is by modifying the php.ini file:

  1. Locate the php.ini File:
    • Use your hosting provider’s file manager or an FTP client to find the php.ini file.
  2. Edit the php.ini File:
    • Open the file and look for the following directives:iniCopy codeupload_max_filesize = 120M post_max_size = 120M
    • Update the values as needed (e.g., 120M).
  3. Restart the Web Server:
    • If you’re on a dedicated server, restart the web server to apply the changes.

2. Modify the .htaccess File

If you don’t have access to php.ini, you can try modifying the .htaccess file:

  1. Open the .htaccess File:
    • Locate this file in the root directory of your WordPress installation.
  2. Add the Following Lines:apacheCopy codephp_value upload_max_filesize 120M php_value post_max_size 120M
  3. Save the Changes:
    • Save the file and test your upload again.

3. Use cPanel to Change PHP Settings

If your hosting provider uses cPanel, you can easily change the upload limits:

  1. Access cPanel:
    • Log in to your cPanel account.
  2. Find the PHP Configuration:
    • Look for the “Select PHP Version” or “MultiPHP INI Editor” option.
  3. Edit the Settings:
    • In the editor, find upload_max_filesize and post_max_size and set them to 120M.
  4. Save Changes:
    • Save your changes, and the new limits should take effect immediately.

4. Update the wp-config.php File

Another option is to add the following lines to your wp-config.php file:

5. Custom php.ini File

If your host allows it, create a custom php.ini file in your WordPress root directory:

  1. Create a New File:
    • Name it php.ini.
  2. Add the Following Lines:iniCopy codeupload_max_filesize = 120M post_max_size = 120M
  3. Save the File.

Conclusion

By following these steps, you should be able to resolve the “The uploaded file exceeds the upload_max_filesize directive in php.ini” error on your WordPress site. Adjusting the upload limits will help you successfully upload larger files without any issues.

For a visual guide on fixing this issue, check out the video below:

Leave a Comment

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

COMMANDEZ MAINTENANT
× Chat with us!