Phenomenon description
To view the parameters, go to WordPress [Tools → Site Health → Information → Media Processing].
Blog Resources and Services
- upload_max_filesize = 20M
- post_max_size = 20M
The PHP configuration has been adjusted, and after refreshing the backend, the media upload page still displays the message: Maximum upload file size: 1 MB.
Uploading files larger than 1MB results in an error, and many people repeatedly modify php.ini .user.iniwithout success, getting stuck in a vicious cycle.
Principle Review
Many developers mistakenly believe that upload limits are only controlled by PHP. The complete request chain sequence is as follows:
Client → Nginx/Apache → PHP → WordPress
Priority is restricted from top to bottom; after upstream interception, the request never reaches PHP.
By default, Nginx
client_max_body_size 1Mtruncates requests before they reach PHP.WordPress displays a PHP configuration file size of 20MB, but the actual upload is intercepted by the web server, resulting in a strange discrepancy between the parameters displayed and those shown on the front end.
scripting language
First, fix potential PHP configuration issues (basic specifications).
Current configuration flaw: post_max_sizeIt is recommended to exceed upload_max_filesize .
File and form-attached data will take up POST space, and if the two are equal, it is very easy to trigger a hidden limit overrun.
Recommended final configuration ( .user.inigeneral /php.ini)
ini
upload_max_filesize = 20 M
post_max_size = 24 M
memory_limit = 256 M
max_execution_time = 300
max_input_time = 300
Modification complete, reload PHP-FPM.
File sharing and hosting
II. Highest probability solution: Adjust Nginx request body limits (essential for BT Panel/Nginx servers)
BT Panel Operation
Website → Settings → Configuration File, server { }add the following line inside:
nginx
client_max_body_size 30M;
Save the configuration and reload Nginx .
Note: Do not write it in the location section; place it at the server level first. Units are case-sensitive;
30mlowercase letters also work.
Directly modify nginx.conf on a standalone server
Global configuration/etc/nginx/nginx.conf
nginx
Computer drives and storage devices
Execute overload command
http {
client_max_body_size 30M;
}
bash
nginx -t
systemctl reload nginx
Third, the second major contributing factor: WordPress’s mandatory restrictions on multisite.
Multi-site upload limits have higher priority than PHP parameters and are easily overlooked.
Operation path:
network
[My Site → Network Management → Settings → Network Settings]
Find the maximum uploaded file size
⚠️ The unit is KB!
If you enter (1MB) here 1024, it will directly override all server-side configurations.
Requires support for 20MB. Modify 20480and save.
IV. Plugin/Theme Interception Troubleshooting
Security plugins, migration plugins, media optimization plugins, and WAF-type plugins can force the upload limit to be overridden through code.
Rapid verification solution:
- Temporarily disable all background plugins
- Switch back to the default WP theme
- Press Ctrl+F5 to force refresh the page and check if the upload limit has returned to normal. If it has, enable each plugin to locate and restrict the source.
V. Restrictions at the CDN, Cloud WAF, and Firewall Levels
If your website uses Cloudflare, Alibaba Cloud WAF, or Tencent Cloud CDN:
Open source
Some service providers’ free plans have a default request size limit of 100MB, but a few custom rules limit it to 1MB.
Investigation methods:
Test the upload by directly connecting the temporary domain to the server (bypassing CDN). If the upload is successful, it confirms that the limitation is on the CDN side. Go to the corresponding backend to adjust the request size limit.
VI. Standard Verification Procedures After Revision
- Reload PHP-FPM and Nginx
- Force refresh your browser (Ctrl+F5, clear page cache).
- Go to the media addition page to view the upper limit prompt.
- Prepare a 1.5MB test file and attempt to upload it for verification.
VII. Emergency Alternative Plan (If there is no time to adjust the configuration)
Do not upload large compressed files or backup files through the WP backend:
Upload to the corresponding directory using SFTP/FTP and then extract:
Blog Resources and Services
- Theme Pack:
wp-content/themes/ - Plugin package:
wp-content/plugins/Media files: Upload directlywp-content/uploads, and can be synchronized with plugins into the library.
Summary of common pitfalls
- Modifying only PHP without modifying Nginx
client_max_body_sizewill still result in failures in 90% of scenarios. post_max_size ≤ upload_max_filesizeThis could create hidden risks of upload failures.- Multi-site administrators forget independent upload limits in network settings
- The service was not reloaded after the configuration was modified, and the browser cache caused a misjudgment.
.user.iniThe file name is misspelled and is missing a leading decimal point.