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

The "The Uploaded File Exceeds the upload_max_filesize Directive in php.ini" error is a common WordPress issue that prevents users from uploading files larger than the server's configured limit. This error occurs when attempting to upload images, videos, or documents that exceed the maximum file size set in the PHP configuration.

Understanding the upload_max_filesize Directive

The upload_max_filesize directive is a PHP setting that determines the maximum size of files that can be uploaded to your server. This setting affects all applications on the server, including WordPress. When this limit is too restrictive, it prevents users from uploading essential media content and can significantly impact website functionality.

The directive works alongside other PHP settings like post_max_size and max_execution_time to control file upload behavior. If any of these values are set too low, file uploads will fail with error messages.

Methods to Increase upload_max_filesize Limit

There are several approaches to resolve this error, depending on your hosting environment and access level. Each method modifies different configuration files to increase the upload limit.

Method 1: Editing php.ini File

This is the most direct method if you have access to the php.ini file

  • Access your hosting control panel (cPanel, Plesk, etc.)

  • Navigate to File Manager and locate the root directory

  • Find and edit the php.ini file

  • Locate the line: upload_max_filesize = 2M

  • Change it to: upload_max_filesize = 64M (or desired size)

  • Also update: post_max_size = 64M

  • Save the file and restart your web server

Method 2: Modifying .htaccess File

If you cannot access php.ini, modify the .htaccess file in your WordPress root directory

php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300

Method 3: Using wp-config.php

Add the following code to your wp-config.php file before the "That's all, stop editing!" line

@ini_set('upload_max_filesize', '64M');
@ini_set('post_max_size', '64M');
@ini_set('max_execution_time', '300');

Method 4: WordPress Functions.php

Add this code to your active theme's functions.php file

@ini_set('upload_max_filesize', '64M');
@ini_set('post_max_size', '64M');
@ini_set('memory_limit', '128M');

Testing and Troubleshooting

After implementing changes, test file uploads by navigating to Media > Add New in your WordPress dashboard. Try uploading a file larger than the previous limit to verify the fix worked.

Common Issues and Solutions

Problem Possible Cause Solution
Changes not taking effect Server caching or multiple php.ini files Clear server cache, contact hosting provider
Still getting size errors Other PHP limits too low Check post_max_size and memory_limit
Uploads timing out max_execution_time too low Increase max_execution_time value
No access to config files Shared hosting restrictions Contact hosting support for assistance

Best Practices

  • Don't set values too high Excessive limits can impact server performance

  • Consider your hosting plan Shared hosting may have stricter limitations

  • Optimize large files Compress images and videos before uploading

  • Regular monitoring Check upload functionality after server updates

  • Backup before changes Always backup configuration files before editing

Alternative Solutions

If increasing upload limits isn't possible or practical, consider these alternatives

  • Use image optimization plugins to compress files automatically

  • Upload large files via FTP directly to the media folder

  • Utilize cloud storage services and embed content

  • Split large files into smaller segments for upload

Conclusion

The upload_max_filesize error can be resolved through various methods, from editing php.ini to modifying WordPress configuration files. Choose the method that matches your hosting environment and access level. Regular testing ensures uploads work correctly, and implementing best practices prevents future issues while maintaining optimal server performance.

Updated on: 2026-03-17T09:01:38+05:30

400 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements