How to Fix ‘The Uploaded File Exceeds the upload_max_filesize Directive in php.ini’ Error

If you have tried to upload an image, plugin, theme, or document to your website and been stopped by the message “the uploaded file exceeds the upload_max_filesize directive in php.ini,” you have hit one of the most common server-side limits in PHP. The good news is that this is a configuration boundary, not a bug or corruption. Once you understand which directive controls the limit and where your hosting environment reads its configuration from, the fix is usually a matter of changing one or two values.

This guide explains what triggers the error, the related PHP directives you need to know, and every practical method to raise the limit, whether you have full server access or only a control panel.

### Key Takeaways
• The error appears when an uploaded file is larger than the `upload_max_filesize` value set in your PHP configuration.
• You must also raise `post_max_size`, and it should be equal to or greater than `upload_max_filesize`.
`memory_limit` should be at least as large as `post_max_size` to avoid silent failures on large uploads.
• You can change these values via php.ini, .htaccess, wp-config.php, .user.ini, or your host’s cPanel MultiPHP INI Editor, depending on your access level.
• On shared hosting, some limits are capped by the provider; support can adjust them when a config file cannot.

What Causes the “upload_max_filesize” Error?

PHP enforces a maximum size for any single file uploaded through an HTML form. That cap is defined by the `upload_max_filesize` directive. When the file you submit is larger than that value, PHP rejects it before your application code ever processes it, and it surfaces the message *”the uploaded file exceeds the upload_max_filesize directive in php.ini.”*

This is a deliberate safety mechanism. Without an upload ceiling, a single oversized request could exhaust server memory, fill disk space, or be used to overload the server. The default value shipped with many PHP builds is intentionally conservative, often around 2 MB, which is why high-resolution photos, video files, plugin archives, and database imports trip the limit so frequently.

The error is most visible in WordPress (uploading media, importing content, or installing a theme), but it applies to any PHP application: Laravel, Magento, custom upload forms, phpMyAdmin imports, and more. The application is simply reporting the server limit back to you.

Which PHP Directives Control Upload Limits?

A successful upload depends on several directives working together, not just one. If you raise `upload_max_filesize` alone, a large upload can still fail because another related limit is lower. Here is what each directive does and the typical default you will encounter.

Directive Common Default Purpose
`upload_max_filesize` 2M Maximum size of a single uploaded file. This is the limit named in the error.
`post_max_size` 8M Maximum size of the entire POST request body, including all files and form fields combined.
`memory_limit` 128M Maximum memory a single PHP script may consume while processing the request.
`max_execution_time` 30 Maximum seconds a script may run before being terminated. Relevant for slow, large uploads.
`max_input_time` 60 Maximum seconds PHP spends parsing input data, including reading the uploaded file.

Defaults vary between PHP versions and hosting builds, so always confirm your live values rather than assuming. You can check them by creating a file containing `

Why Must post_max_size Be Greater Than or Equal to upload_max_filesize?

This relationship trips up many people, so it deserves its own explanation. `post_max_size` governs the total size of the entire request, while `upload_max_filesize` governs only the single file inside it. Because the file is *part* of the POST body, the body can never be smaller than the file it carries.

If `upload_max_filesize` is set to 64M but `post_max_size` is left at 8M, the request is rejected the moment its total size crosses 8 MB, long before the per-file limit is reached. The result is a confusing failure where the per-file setting looks correct but uploads still break.

The rule to remember: `memory_limit` >= `post_max_size` >= `upload_max_filesize`. Set `post_max_size` a little higher than `upload_max_filesize` to leave room for other form fields and request overhead, and keep `memory_limit` comfortably above both.

A subtle behavior worth knowing: when `post_max_size` is exceeded, PHP does not always return the same friendly error. The `$_POST` and `$_FILES` superglobals can come back completely empty, with no warning shown to the user. So if a form silently submits nothing on large uploads while small ones work fine, suspect `post_max_size` rather than `upload_max_filesize`. The named “upload_max_filesize” error is actually the *more* informative of the two failure modes.

How Do You Fix the Error by Editing php.ini?

If you have access to your server’s php.ini file, this is the most direct fix because it changes the global configuration. Locate the file (its path is shown in `phpinfo()` under “Loaded Configuration File”), then find and update these lines:

“`ini upload_max_filesize = 64M post_max_size = 128M memory_limit = 256M max_execution_time = 300 max_input_time = 300 “`

Save the file and restart your web server (or PHP-FPM) so the new values are loaded. Without a restart, your changes will not take effect on most setups. After restarting, reload `phpinfo()` to confirm the values updated.

On dedicated servers and VPS environments you almost always have this access. On shared hosting you typically do not, which is where the alternative methods below come in.

How Do You Increase the Limit with .htaccess?

When you cannot edit the main php.ini but your server runs Apache with mod_php, you can override these values from a `.htaccess` file in your site’s root directory. Add the following:

“`apache php_value upload_max_filesize 64M php_value post_max_size 128M php_value memory_limit 256M php_value max_execution_time 300 php_value max_input_time 300 “`

Be aware that `.htaccess` PHP overrides only work with mod_php. If your host runs PHP as CGI, FastCGI, or PHP-FPM (increasingly the default), these directives will be ignored, and adding them can even produce a 500 Internal Server Error. If that happens, remove the lines and use the `.user.ini` method instead.

How Do You Use a .user.ini File?

For servers running PHP via FastCGI or PHP-FPM, the modern equivalent of per-directory configuration is the `.user.ini` file. Create a file named `.user.ini` in your site’s root directory with this content:

“`ini upload_max_filesize = 64M post_max_size = 128M memory_limit = 256M “`

Changes to `.user.ini` are not always instant. PHP caches the file and re-reads it based on the `user_ini.cache_ttl` setting (commonly 300 seconds), so you may need to wait a few minutes for the new values to apply. This method works on many shared hosting plans where `.htaccess` overrides do not.

Can You Fix This in wp-config.php for WordPress?

WordPress users have one more option. Adding a line to `wp-config.php` can raise the PHP memory limit, which helps with the `memory_limit` part of the equation:

“`php define( ‘WP_MEMORY_LIMIT’, ‘256M’ ); “`

It is important to set expectations here: `wp-config.php` reliably controls WordPress’s memory handling, but it cannot raise `upload_max_filesize` or `post_max_size` on its own, because those are enforced by PHP before WordPress runs. Some setups allow `@ini_set()` calls in this file to attempt changes, but success depends entirely on the server’s PHP handler. Treat `wp-config.php` as a complement to the other methods, not a replacement for them.

How Do You Change Limits in cPanel’s MultiPHP INI Editor?

If your hosting uses cPanel, the MultiPHP INI Editor is the simplest and most reliable method, with no file editing or server restarts required. The steps are:

  1. Log in to cPanel and open MultiPHP INI Editor (under the Software section).
  2. Switch to the Editor Mode tab, or use Basic Mode for guided fields.
  3. Select the domain or PHP version you want to configure.
  4. Update `upload_max_filesize`, `post_max_size`, and `memory_limit` to your desired values.
  5. Click Apply to save.

Because cPanel writes the changes to the correct configuration location for your active PHP handler and applies them immediately, this approach sidesteps the `.htaccess` versus `.user.ini` guesswork entirely. It is the recommended route for most shared and reseller hosting users.

Do Hosting Plan Limits Affect upload_max_filesize?

Yes. Even when you edit a configuration file correctly, your hosting provider can impose a hard ceiling that your settings cannot exceed. Shared hosting plans often cap upload and memory limits to protect server stability and fairly distribute resources among accounts.

If you set `upload_max_filesize` to 256M but uploads still fail at a lower threshold, the provider’s global limit is almost certainly overriding yours. In that situation, no amount of local configuration will help, and the correct step is to contact your host’s support team to request an increase or to confirm the maximum your plan allows. A quality host will either raise the limit for you or explain the constraint clearly.


Hosting With PHP Configuration That Just Works

Wrestling with upload limits is far easier on hosting built to let you adjust PHP settings without friction. DarazHost plans include the cPanel MultiPHP INI Editor, so you can raise `upload_max_filesize`, `post_max_size`, and `memory_limit` from a clean interface in seconds, no SSH or manual file edits required.

DarazHost also offers multiple selectable PHP versions per domain, so you can match your application’s requirements, along with generous default upload and resource limits suited to media-heavy sites, large plugin installs, and database imports. And when a value needs to go beyond the standard plan ceiling, our 24/7 support team can review and adjust the limits for you directly. If file-upload errors are slowing you down, DarazHost gives you both the self-service controls and the human help to clear them quickly.


Frequently Asked Questions

What is a safe value to set for upload_max_filesize?

Set it to a little above the largest file you realistically need to upload. Common choices are 32M, 64M, or 128M. Avoid setting it unnecessarily high, since very large limits increase exposure to memory exhaustion and abusive oversized requests. Always raise `post_max_size` and `memory_limit` to match.

Why does my upload still fail after I raised upload_max_filesize?

The most likely cause is that `post_max_size` is still lower than your upload, or that your hosting plan enforces a global cap. Confirm that `post_max_size` is greater than or equal to `upload_max_filesize`, that `memory_limit` is higher than both, and that your changes actually loaded by checking `phpinfo()`. If the live values did not change, your edits are being applied to a file your PHP handler does not read.

Do I need to restart anything after changing php.ini?

When editing the main php.ini, yes, you must restart the web server or PHP-FPM for changes to take effect. Changes made through cPanel’s MultiPHP INI Editor or a `.user.ini` file do not require a manual restart, though `.user.ini` may take a few minutes to refresh from cache.

Why are my form fields empty instead of showing an error?

When the total request exceeds `post_max_size`, PHP may discard the entire request body, leaving `$_POST` and `$_FILES` empty with no obvious error. This is a strong sign that `post_max_size` is too low, even when `upload_max_filesize` looks correct.

Can I fix this without any server or file access?

If you only have a control panel, use the cPanel MultiPHP INI Editor to update the values. If you have no panel access at all, or your plan enforces a hard limit, contact your hosting provider’s support team and ask them to raise the upload and memory limits for your account.

About the Author

Leave a Reply