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.
<strong>Note:</strong> 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 <code>upload_max_filesize</code> and <code>post_max_size</code> in the "Tools" → "Site Health" → "Info" → "Server" section.
Method 1: Configure in <code>wp-config.php</code>
This is the easiest method. Add the following line to <code>wp-config.php</code> 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 <code>ini_set()</code>, 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 <code>php.ini</code>.
Method 2: Configure with .htaccess
If you are using an Apache server, you can override PHP settings in the <code>.htaccess</code> file. Add the following to the <code>.htaccess</code> 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, <code>.htaccess</code> 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 <code>php.ini</code> (or <code>.user.ini</code>).
; 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 <code>php.ini</code>. In that case, creating a <code>.user.ini</code> file in the WordPress root directory and writing the same content may take effect.
<strong>Note:</strong> Set <code>post_max_size</code> to a value larger than <code>upload_max_filesize</code>. <code>post_max_size</code> 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 <code>functions.php</code>. 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 <code>PHP</code> 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 <code>upload_max_filesize</code> and <code>post_max_size</code>
- 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 <code>post_max_size</code> greater than or equal to <code>upload_max_filesize</code>?
Testing After Configuration Changes
After changing upload limits, always test with actual files. DevLab provides test files of various sizes.
- <a href="/ja/reference/wordpress-upload-limit/">WordPress Upload Limit Reference</a> — List of default upload limits for each hosting environment
- <a href="/ja/files/threshold/">Boundary Value Test Files</a> — Test at exact limit sizes
- <a href="/ja/files/images/">Image Test Files</a> — 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 <code>.htaccess</code> or <code>php.ini</code>. After making configuration changes, verify that uploads succeed using DevLab's test files.
Test files for this article
- → <a href="/ja/files/threshold/" class="text-primary-600 dark:text-primary-400 hover:underline">Threshold Test Files (9.9MB / 10MB / 10.1MB)</a>
- → <a href="/ja/files/images/jpg/" class="text-primary-600 dark:text-primary-400 hover:underline">JPEG Image Test Files List</a>
Related articles
- → <a href="/ja/blog/how-to-test-upload-limit/" class="text-primary-600 dark:text-primary-400 hover:underline">How to Properly Test File Upload Limits</a>
- → <a href="/ja/blog/mb-vs-mib-file-size/" class="text-primary-600 dark:text-primary-400 hover:underline">MB and MiB Are Different! The Pitfalls of File Size Units</a>