Skip to main content
Wordpress Technical Support

How to Increase Upload File Size & PHP Memory Limits in WordPress

How to Increase Upload File Size & PHP Memory Limits in WordPress

When uploading large media assets, product catalogs, zip archives, or database backup imports, you may encounter one of these errors:

“The uploaded file exceeds the uploadmaxfilesize directive in php.ini.”

“413 Request Entity Too Large”

“Fatal error: Allowed memory size of 134217728 bytes exhausted”

WordPress imposes upload limits dictated by the underlying PHP environment and server settings. This guide explains how to increase these limits across php.ini, .htaccess, .user.ini, and wp-config.php.


1. The Four Critical Directives

To increase upload capacity and execution stability, four interrelated PHP settings must be coordinated:

Directive Description Recommended Setting
upload_max_filesize

Maximum size of an individual uploaded file. | 64M or 128M |
| post_max_size | Maximum total size of POST data (must be $ge$ upload_max_filesize). | 128M or 256M |
| memory_limit | Maximum RAM a single PHP process may consume (must be $ge$ post_max_size). | 256M or 512M |
| max_execution_time | Maximum seconds a script can run before being terminated. | 300 (5 minutes) |

Important: > The rule of thumb hierarchy must always be maintained:

$$text{uploadmaxfilesize} le text{postmaxsize} le text{memorylimit}$$

If upload_max_filesize is 64M but post_max_size is 32M, any upload over 32MB will fail silently or throw a 500 error.


2. Method A: Updating php.ini (Recommended for Local / Dedicated Servers)

On local environments (XAMPP) or VPS instances where you control PHP, editing php.ini is the cleanest and most permanent solution.

  1. Locate your active php.ini:

– XAMPP Windows: C:xamppphpphp.ini
– Ubuntu/Debian Apache: /etc/php/8.2/apache2/php.ini
– Ubuntu/Debian FPM: /etc/php/8.2/fpm/php.ini

  1. Open php.ini in an editor and update the following directives:
upload_max_filesize = 128M
post_max_size = 128M
memory_limit = 512M
max_execution_time = 300
max_input_time = 300
max_input_vars = 3000
  1. Restart the web server service:

– On XAMPP: Stop and Start Apache in the XAMPP Control Panel.
– On Linux: sudo systemctl restart apache2 or sudo systemctl restart php8.2-fpm.


3. Method B: Using .htaccess (Apache Shared Hosting)

If your host runs Apache with mod_php, you can define PHP flags directly in the root .htaccess file:

# Increase PHP Upload Limits
<IfModule mod_php.c>
    php_value upload_max_filesize 128M
    php_value post_max_size 128M
    php_value memory_limit 512M
    php_value max_execution_time 300
    php_value max_input_time 300
</IfModule>
Warning: > If your server runs PHP via PHP-FPM or FastCGI (common on modern hosting), putting php_value inside .htaccess can cause a 500 Internal Server Error. If this occurs, remove the block immediately and use Method C instead.

4. Method C: Using .user.ini (PHP-FPM / cPanel Hosting)

On modern servers running PHP-FPM or suPHP, create a file named .user.ini in the WordPress root directory:

upload_max_filesize = 128M
post_max_size = 128M
memory_limit = 512M
max_execution_time = 300

.user.ini is read automatically by PHP-FPM for the directory and all subdirectories. Changes take effect within 5 minutes.


5. Method D: Setting Memory Constants in wp-config.php

WordPress has its own internal memory cap defined in wp-config.php, which can throttle execution even if php.ini allows more RAM.

Add these two constants to wp-config.php:

// Increase WordPress Front-end Memory Limit
define('WP_MEMORY_LIMIT', '256M');

// Increase WordPress Admin Dashboard Memory Limit (Used for heavy media processing and exports)
define('WP_MAX_MEMORY_LIMIT', '512M');

6. Nginx client_max_body_size Configuration

If you are using Nginx as a reverse proxy or web server, Nginx has its own request body limit (client_max_body_size) which defaults to just 1 MB!

If this limit is exceeded, Nginx throws an HTTP 413 Request Entity Too Large error before the request ever reaches PHP.

Add or update client_max_body_size inside the http { ... } or server { ... } block in /etc/nginx/nginx.conf:

server {
    server_name example.com;
    client_max_body_size 128M;
    # ... rest of configuration ...
}

Reload Nginx:

sudo nginx -t && sudo systemctl reload nginx


7. Verifying Active Limits Inside WordPress

To verify your new limits inside the WordPress admin dashboard:

  1. Go to Tools > Site Health in the admin sidebar.
  2. Click the Info tab.
  3. Expand the Server section to verify:

– PHP memory limit
– PHP upload max filesize
– PHP post max size
– PHP time limit

  1. Expand the WordPress Constants section to verify:

– WPMEMORYLIMIT
– WPMAXMEMORYLIMIT

Was this technical article helpful?

Help us continuously refine Xyphla documentation.