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

Estimated read time 3 min read

In the world of web development, encountering errors is inevitable, but understanding and resolving them is crucial to maintaining a smooth user experience. One common challenge developers face is the “Uploaded file exceeds the upload_max_filesize directive in php.ini” error. This article aims to shed light on this issue and provide a comprehensive guide to troubleshoot and fix it.

Understanding the Error:

The error message indicates that the file being uploaded to the server surpasses the maximum file size limit defined in the php.ini configuration file. This limit is set to prevent server overload and potential security risks associated with large file uploads.

Steps to Resolve the Error:

  1. Check php.ini Configuration:
  • Locate your php.ini file, which is typically found in the PHP installation directory.
  • Look for the upload_max_filesize directive and ensure it is set to a value that accommodates your file size requirements. For example, if you need to allow uploads of up to 10 megabytes, set it as follows:
    ini upload_max_filesize = 10M
  1. Adjust post_max_size:
  • The post_max_size directive in php.ini should be equal to or greater than upload_max_filesize. Adjust it accordingly:
    ini post_max_size = 10M
  1. Restart the Web Server:
  • After making changes to php.ini, restart your web server to apply the modifications.
  1. Check .htaccess Configuration:
  • If you’re working with an Apache server, check your project’s .htaccess file for any conflicting configurations. Ensure it doesn’t override the settings in php.ini.
  1. Server Resource Limits:
  • Confirm with your hosting provider that there are no server-wide restrictions on file upload sizes that override your php.ini settings.
  1. Verify Changes with phpinfo():
  • Create a PHP file with the following content to check the effective configuration:
    php <?php phpinfo(); ?>
    Open this file in your browser and search for “upload_max_filesize” to verify that your changes have taken effect.
  1. Use ini_set() Function (if applicable):
  • In some cases, you may be able to adjust the upload size limit within your application code using the ini_set() function. However, this method is subject to server restrictions and might not work in all environments.


Troubleshooting the “Uploaded file exceeds the upload_max_filesize directive in php.ini” error requires a careful examination of server configurations. By following the steps outlined in this guide, you should be able to identify and resolve the issue, ensuring that your web application can handle file uploads seamlessly. Remember to always consider the specific requirements of your project when adjusting these settings to strike the right balance between security and functionality.

You May Also Like

More From Author