Increase upload_max_filesize (Uploaded file exceeds the upload_max_filesize directive)
Increase upload_max_filesize (Uploaded file exceeds the upload_max_filesize directive)
If you encounter the error “Uploaded file exceeds the upload_max_filesize directive” in WordPress, it means your server’s PHP configuration limits the maximum file size you can upload. This often blocks you from uploading large media files or plugins. The quick fix is to increase the upload_max_filesize value in your PHP settings.
Quick Fix
- Edit your
php.inifile (or create one if it doesn’t exist) and add or update this line:upload_max_filesize = 64M - Also increase
post_max_sizeto the same or larger value:post_max_size = 64M - Restart your web server (Apache, Nginx, LiteSpeed) to apply changes.
- Verify the new limits in WordPress by going to
Media > Add Newor using a PHP info plugin.
Why this happens
PHP has built-in limits on file upload sizes to prevent server overload and abuse. The upload_max_filesize directive controls the maximum size of an uploaded file, while post_max_size controls the maximum size of POST data allowed. If your file exceeds these limits, PHP rejects the upload and WordPress shows the error.
By default, many hosting providers set these values low (e.g., 2MB or 8MB) to conserve resources. To upload larger files, you must increase these limits manually.
Step-by-step
1. For Apache or LiteSpeed servers
- Locate your
php.inifile. Common locations:/etc/php/7.x/apache2/php.ini/usr/local/lib/php.ini- Use
phpinfo()to find the loaded config file.
- Edit the
php.inifile and update or add:upload_max_filesize = 64M post_max_size = 64M memory_limit = 128M max_execution_time = 300 max_input_time = 300 - Save the file and restart Apache or LiteSpeed:
sudo systemctl restart apache2 # or for LiteSpeed sudo systemctl restart lsws - Check changes with a PHP info file or WordPress media uploader.
2. For Nginx servers
- Edit your PHP-FPM
php.inifile (location similar to Apache). - Update the same directives as above:
upload_max_filesize = 64M post_max_size = 64M memory_limit = 128M max_execution_time = 300 max_input_time = 300 - Edit your Nginx site configuration file (e.g.,
/etc/nginx/sites-available/example.com) and add or update:client_max_body_size 64M; - Restart PHP-FPM and Nginx:
sudo systemctl restart php7.x-fpm sudo systemctl restart nginx - Verify upload limits in WordPress.
3. Using cPanel
- Log in to your cPanel dashboard.
- Go to MultiPHP INI Editor under the Software section.
- Select your domain from the dropdown.
- Set
upload_max_filesizeandpost_max_sizeto your desired values (e.g., 64M). - Save the changes.
- Check your WordPress upload limits.
4. Using Plesk
- Log in to Plesk.
- Go to Domains > example.com > PHP Settings.
- Find
upload_max_filesizeandpost_max_sizeand increase their values. - Save the settings.
- Test upload limits in WordPress.
Works on
| Server | Control Panel | Notes |
|---|---|---|
| Apache | cPanel, Plesk, Manual | Requires php.ini edit and server restart |
| Nginx | cPanel, Plesk, Manual | Requires php.ini and nginx.conf edits + restarts |
| LiteSpeed | cPanel, Manual | Similar to Apache, restart LiteSpeed after changes |
FAQ
-
Q: I increased upload_max_filesize but still get the error. Why?
A: You must also increase
post_max_sizeand ensure your web server (Nginx or Apache) allows larger uploads (e.g.,client_max_body_sizein Nginx). Restart your server after changes. -
Q: Can I increase upload limits via .htaccess?
A: Only on Apache servers with PHP running as an Apache module. Add these lines to your
.htaccess:php_value upload_max_filesize 64M php_value post_max_size 64M -
Q: How do I check current upload limits?
A: Use a PHP info plugin in WordPress or create a
phpinfo.phpfile with:<?php phpinfo(); ?>Then open it in your browser and look for
upload_max_filesize
