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:
- Locate the
php.ini
File:- Use your hosting provider’s file manager or an FTP client to find the
php.ini
file.
- Use your hosting provider’s file manager or an FTP client to find the
- Edit the
php.ini
File:- Open the file and look for the following directives:iniCopy code
upload_max_filesize = 120M post_max_size = 120M
- Update the values as needed (e.g.,
120M
).
- Open the file and look for the following directives:iniCopy code
- 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:
- Open the
.htaccess
File:- Locate this file in the root directory of your WordPress installation.
- Add the Following Lines:apacheCopy code
php_value upload_max_filesize 120M php_value post_max_size 120M
- 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:
- Access cPanel:
- Log in to your cPanel account.
- Find the PHP Configuration:
- Look for the “Select PHP Version” or “MultiPHP INI Editor” option.
- Edit the Settings:
- In the editor, find
upload_max_filesize
andpost_max_size
and set them to120M
.
- In the editor, find
- 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:
phpCopy code@ini_set('upload_max_filesize', '120M');
@ini_set('post_max_size', '120M');
5. Custom php.ini
File
If your host allows it, create a custom php.ini
file in your WordPress root directory:
- Create a New File:
- Name it
php.ini
.
- Name it
- Add the Following Lines:iniCopy code
upload_max_filesize = 120M post_max_size = 120M
- 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: