5 Methods to Increase the WordPress Upload Limit
Have you ever encountered an error saying "exceeds the upload limit" when trying to upload a media file in WordPress? The default upload limit in WordPress varies depending on the server environment, but in most cases it is set to 2MB–64MB. This article explains five methods to increase the upload limit with code examples.
Note: Always back up before making configuration changes. Also, some methods may not be available on shared hosting.
Check current limit
First, let's check the current settings. The current upload limit is displayed on the WordPress admin screen's "Media" → "Add new media file" page. You can also check the values of upload_max_filesize and post_max_size in the "Tools" → "Site Health" → "Info" → "Server" section.
Method 1: Configure in wp-config.php
This is the easiest method. Add the following line to wp-config.php in the WordPress root directory.
// wp-config.php に追加(「編集が必要なのはここまでです」の行の上に記述)
@ini_set('upload_max_filesize', '64M');
@ini_set('post_max_size', '64M');
@ini_set('max_execution_time', '300');
@ini_set('max_input_time', '300');
This method uses PHP's ini_set(), so it may not be reflected depending on the server configuration. In particular, it has no effect in environments where these values are fixed in php.ini.
Method 2: Configure with .htaccess
If you are using an Apache server, you can override PHP settings in the .htaccess file. Add the following to the .htaccess file in the WordPress root directory.
# .htaccess に追加
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300
php_value memory_limit 256M
With Nginx servers, .htaccess cannot be used, so you must handle this in the server configuration file.
# Nginx の設定(/etc/nginx/conf.d/ 配下)
client_max_body_size 64m;
Method 3: Configure with php.ini
If you can directly edit the server's PHP configuration file, this is the most reliable method. Write the following in php.ini (or .user.ini).
; php.ini に追記
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
max_input_time = 300
memory_limit = 256M
On shared hosting, you may not be able to directly edit php.ini. In that case, creating a .user.ini file in the WordPress root directory and writing the same content may take effect.
Note: Set post_max_size to a value larger than upload_max_filesize. post_max_size is the limit for entire form data, including form fields and overhead in addition to the file itself.
Method 4: Configure with functions.php
This is a method to add a filter to the theme's functions.php. Since settings are lost when the theme is updated, we recommend implementing this using a child theme or custom plugin.
// functions.php または カスタムプラグインに追加
@ini_set('upload_max_filesize', '64M');
@ini_set('post_max_size', '64M');
// WordPress のアップロードサイズフィルター
add_filter('upload_size_limit', function($size) {
return 64 * 1024 * 1024; // 64 MiB
});
// マルチサイトの場合
add_filter('upload_size_limit', function($size) {
return 64 * 1024 * 1024;
}, 20);
Method 5: Configure with hosting panel
Many rental servers and hosting services allow you to change PHP settings from their control panels (such as cPanel, Plesk, ConoHa, and Xserver).
- Log in to the hosting control panel
- Look for the PHP configuration or php.ini settings menu.
- Change the values of
upload_max_filesizeandpost_max_size - Save the settings and restart PHP if necessary
This method is the most reliable because the configuration is applied at the server level, ensuring it cannot be overridden by other methods.
Checkpoints when settings are not applied
- Did you restart the web server (Apache/Nginx)?
- If you're using PHP-FPM, did you restart PHP-FPM as well?
- Check if CDN or Reverse Proxy Limits Request Size
- In WordPress multisite, network admin settings may take precedence
- Is
post_max_sizegreater than or equal toupload_max_filesize?
Testing After Configuration Changes
After changing upload limits, always test with actual files. DevLab provides test files of various sizes.
- WordPress Upload Limit Reference — List of default upload limits for each hosting environment
- Boundary Value Test Files — Test at exact limit sizes
- Image Test Files — Verify with actual media uploads
Summary
There are multiple ways to increase the WordPress upload limit, but the applicable method depends on your server environment. First try configuring it in your hosting panel; if that's not available, use .htaccess or php.ini. After making configuration changes, verify that uploads succeed using DevLab's test files.