Increase WordPress Upload Size Safely
In this article
Running into the “The uploaded file exceeds the upload_max_filesize directive” error is a common WordPress frustration. This guide walks you through safely increasing the maximum file upload size, covering the four main methods you can use depending on your hosting setup. You’ll learn how to do it without breaking your site, what to do if a method doesn’t work, and how to avoid common pitfalls.
What You’ll Need
- Access to your WordPress admin dashboard (wp-admin).
- FTP credentials or a file manager in your hosting control panel (cPanel, Plesk, etc.).
- Access to your hosting control panel to edit PHP settings (if not using FTP).
- A code editor or text editor to modify files.
Step-by-Step
- Check your current upload limit. In your WordPress dashboard, go to Media > Add New. The upload limit is displayed at the bottom of the screen (e.g., “Maximum upload file size: 2 MB”). Note this value so you can confirm the change later.
- Try the simplest method first: a plugin. Install a plugin like “Increase Max Upload Filesize” or “WP Increase Upload Limits” from the WordPress repository. Go to Plugins > Add New, search for one, install, and activate. Then go to Settings > Upload Limits (or the plugin’s settings page) and set the desired size. This method is safe and reversible. If it works, you’re done.
- Edit your theme’s functions.php file (if the plugin method fails). Go to Appearance > Theme File Editor, select functions.php, and add the following code at the end:
@ini_set( 'upload_max_size' , '64M' ); @ini_set( 'post_max_size', '64M' ); @ini_set( 'max_execution_time', '300' );
Replace “64M” with your desired size. Click Update File. This method works on many shared hosts, but if you see a fatal error, immediately remove the code (see Troubleshooting). - Create a custom php.ini file (if allowed by your host). Using FTP or your hosting file manager, navigate to your WordPress root directory (where wp-config.php is located). Create a new file named php.ini and add:
upload_max_filesize = 64M post_max_size = 64M max_execution_time = 300
Save and upload. This overrides the server’s default PHP settings. If it doesn’t work, your host may not allow per-directory PHP settings; move to the next step. - Edit the .htaccess file (if php.ini is not allowed). In your WordPress root directory, open .htaccess (if it doesn’t exist, create one). Add the following lines at the top:
php_value upload_max_filesize 64M php_value post_max_size 64M php_value max_execution_time 300
Save and upload. This works on Apache servers with mod_php enabled, but not on all hosts (especially those using CGI/FastCGI). - Contact your hosting provider. If none of the above work, log in to your hosting control panel and look for a “PHP Settings” or “PHP Configuration” area (often in cPanel under “Select PHP Version” > “Switch to PHP Options”). You can change upload_max_filesize and post_max_size there. If you can’t find it, submit a support ticket asking them to increase the upload limit. Many shared hosts have hard caps (e.g., 64MB or 128MB) that you cannot exceed.
- Verify the change. Go back to Media > Add New in WordPress and check the displayed limit. Try uploading a file larger than your previous limit to confirm it works.
Common Mistakes
- Editing the wrong file. The php.ini file must be in the WordPress root directory, not in a subfolder. Similarly, editing .htaccess in a subdirectory won’t affect the whole site.
- Setting values too high. Increasing the limit to 1GB on a shared host might cause performance issues or be ignored by the server. Start with a realistic value like 64MB or 128MB.
- Forgetting to increase post_max_size. The post_max_size must be at least as large as upload_max_filesize; otherwise, uploads still fail.
- Using the wrong syntax. In php.ini, use
upload_max_filesize = 64M(no quotes). In .htaccess, usephp_value upload_max_filesize 64M(space, not equals). - Not clearing caching plugins. If you have a caching plugin, it might serve old PHP settings. Clear all caches after making changes.
Tips
- Always back up your site (at least the files you’re editing) before making changes.
- Use a child theme when editing functions.php so your changes aren’t lost when the theme updates.
- If you’re on managed WordPress hosting (like WP Engine, Kinsta), you usually can’t edit PHP files; instead, use their control panel or contact support.
- Consider whether you really need a huge limit. For most sites, 64MB is plenty for images and PDFs. For video, it’s better to use a streaming service or a dedicated media hosting solution.
- Keep the limit as low as possible for security; a larger upload limit increases the risk of someone uploading malicious files.
Troubleshooting
- After editing functions.php, you see a fatal error or a white screen. This usually means a syntax error. Connect via FTP, navigate to wp-content/themes/your-theme/functions.php, and remove the lines you added. If you can’t access the dashboard, use FTP to rename the theme folder to force WordPress to switch to a default theme temporarily.
- The upload limit hasn’t changed after adding php.ini or .htaccess. This means your host doesn’t allow those directives. Try the other method, or contact support. Also, double-check that you edited the correct file and that it’s in the root directory.
- You get a “413 Request Entity Too Large” error. This is from the web server (Apache/Nginx), not PHP. You’ll need to increase client_max_body_size in Nginx or LimitRequestBody in Apache, which usually requires server-level access. Contact your host.
- Uploads fail with a generic error even after increasing the limit. Check the PHP memory limit (
memory_limit) as well; it should be at least 128M. You can addmemory_limit = 128Mto your php.ini orphp_value memory_limit 128Mto .htaccess. - Changes revert after a while. Some hosts reset PHP settings during server restarts. If that happens, the only permanent solution is to ask your host to change the server-wide PHP configuration.
Frequently Asked Questions
What is the default WordPress upload limit?
It varies by host, but typically it’s 2MB, 8MB, or 16MB. You can check yours in Media > Add New.
Why can’t I increase it beyond a certain size?
Your hosting provider enforces a hard limit. If you’re on shared hosting, they often cap uploads to protect server resources. You may need to upgrade to a VPS or dedicated server for larger limits.
Is it safe to edit functions.php?
It’s safe if you use correct syntax and back up the file first. A single typo can break your site, but you can fix it by removing the code via FTP.
Will increasing the upload size slow down my site?
Not directly, but allowing larger files can increase server load when multiple users upload simultaneously. It’s best to keep the limit as low as possible for your needs.
Can I set different limits for different users?
Yes, with a plugin like “User Role Editor” or “Upload Max File Size” you can set per-role limits. However, the server-side PHP limit still applies as a maximum.
Do I need to increase post_max_size as well?
Yes, post_max_size must be larger than upload_max_filesize because the file is sent as part of the POST request. A good rule is to set it 10-20% higher.