Summary of Solutions to the Problem of WordPress Upload File Size Exceeding php.ini Limits
This article was last updated 287 days ago. The information within may have evolved or changed; if anything is outdated or broken, please feel free to leave a message in the comments section.
Article Abstract
To address the issue of WordPress uploading large files being restricted by php.ini, it can be resolved by modifying the .htaccess file (applicable to Docker and Apache deployments), adjusting php.ini parameters, modifying the theme's functions.php, or using plugins. Among these, the .htaccess method is more friendly to Docker deployments, while directly uploading files to the specified directory is effective but requires permission support. Different solutions are suitable for different deployment scenarios; for example, source code deployment can prioritize adjusting php.ini, while when permissions are restricted, you can try plugins or bypass PHP's direct upload method, though the latter may affect the administrative backend workflow.
Qwen3-14B · 2026-06-18

Preface

Friends who use WordPress to build websites, if you have the following application scenarios: installing new themes, installing plugins, uploading files and images, etc., you have probably encountered the embarrassing problem shown in the figure below:

image.png

This is because WordPress is developed using the PHP language, and php.ini is the main configuration file of PHP. It defines the global settings of PHP, including parameters such as upload_max_filesize and post_max_size. These settings apply by default to all PHP scripts running on the server (WordPress is certainly no exception). Because some parameters have default values that are set too conservatively, such as the default value of ”upload_max_filesize” being 2M, uploading files larger than 2M in WordPress will result in the error shown in the figure above.

This article lists several ways to solve this problem. You can choose the solution that best suits your actual environment.

Summary of Solutions

Modify php.ini (Generally not recommended)

This method has the widest impact (it affects all PHP scripts on the entire host, use with caution) and is normally not recommended (neither for source code deployment nor Docker deployment of WordPress). However, if you must choose between the two, using this method is slightly more convenient when deploying WordPress via source code. Of course, you also need administrator privileges on the deployment host.

  1. Find the php.ini file :
    On your server, find php.ini the location of the file. This file is usually located in the PHP installation directory, or in your hosting control panel.
  2. Edit the php.ini file :
upload_max_filesize = 100M #默认2M,这就是无法上传大文件的罪魁祸首,改成你需要的数值,比如100M
post_max_size = 64M #默认8M,这个参数影响上传文章的大小,一般8M也够了,可以改大点,比如64M
  1. Restart the server :
    After modifying, save the file and restart your web server (such as Apache or Nginx) for the changes to take effect.

Modify .htaccess file (Recommended for Docker deployment and Apache source code deployment)


**Item 9:**.htaccess file is a file used to configure the behavior of the Apache Web server. Its name is an abbreviation for “hypertext access”, usually located in the root directory or subdirectories of the website. The effective scope of the file is its directory and its subdirectories. Each directory can have its own .htaccess file, and can override the settings of the parent directory. Through the .htaccess file, website administrators can have fine-grained control over the server's configuration without directly modifying Apache's main configuration file.


Since modifying php.ini has too wide an impact and high permission requirements, it is often not suitable. Moreover, this method is actually more suitable for WordPress source code deployment scenarios. Currently, most friends prefer to use Docker for deployment; if this method is adopted, you need to enter the Docker container to modify php.ini, which is very inconvenient.

In this case, modifying the ”.htaccess” file is a choice with a small impact (generally, servers allow the .htaccess file to override PHP settings). Applicable scenarios:
WordPress deployed via Docker (because the image made by Docker uses Apache as the web server)
Friends who use Apache as the web server for WordPress source code deployment and have management permissions for the WordPress site directory

In the WordPress root directory (if deployed via Docker, it is mounted to the container's ”wordpress/html/” directory using the -v parameter on the host machine) under the .htaccess file (hidden file), add the following lines:

php_value upload_max_filesize 100M
php_value post_max_size 64M

As shown in the figure below:

image.png

After that, when the Apache server reads the .htaccess file, it will apply these configurations, thereby overriding the default values in php.ini.

Note: For WordPress source code deployment scenarios, modifying .htaccess is only suitable when the web server is Apache. If the web server is Nginx, this method is not suitable; instead, you need to modify both php.ini and the Nginx configuration file. In addition to modifying php.ini as described earlier, you also need to add or modify the following line in the server block (server {}) or location block (location {}) of the Nginx configuration file:

client_max_body_size 64M;

Then save the file and restart Nginx for it to take effect.

Modify the WordPress theme's functions.php or use a dedicated plugin

In addition to the above two methods, you can also try to solve the upload issue by modifying the WordPress theme's functions.php file or using a dedicated plugin.

Modify the theme's functions.php

The functions.php file is located in the directory of the theme being used, with the path ”/wordpress/html/wp-content/themes/xxxxx”,
add the following content:

@ini_set( 'upload_max_size' , '64M' );
@ini_set( 'post_max_size', '64M');
@ini_set( 'max_execution_time', '300' );

Note: This method may not always succeed, because modifying PHP configurations via ini_set() in functions.php is not always effective, especially when encountering web server configuration limits or hosting environment constraints. To ensure that upload limits can be correctly modified, it is usually necessary to directly edit the php.ini file and the web server's configuration file. If using Docker, you also need to ensure that the Docker container's configuration correctly reflects these changes. Therefore, if it doesn't succeed, that is also normal~.

Dedicated plugins

Some dedicated plugins, such as ”Increase Maximum Upload File Size” and ”WP Upload Size”, both provide the function to directly modify the upload file size limit. Unfortunately, however, this method, like modifying the theme's functions.php file, may not necessarily take effect (because it is essentially restricted by php.ini).

Ultimate Method: Bypass the PHP level and upload directly

If the previous methods are considered acting within the rules, focusing on reasonably and legally breaking through PHP's default upload limits, the remaining method directly skips the PHP level and faces the essence of the problem. What is the essence of uploading and installing a theme in the WordPress admin backend?

Essentially, installing a theme in WordPress is actually uploading the theme's zip package to the ”/wordpress/html/wp-content/themes/” path and then unzipping it; if installing a plugin, it is uploading the plugin's zip package to the ”/wordpress/html/wp-content/plugins/” path and then unzipping it; if uploading an image, it is uploading the image directly to the ”/wordpress/html/wp-content/uploads/xxxx/xx/” path.

So, since that is the essence of it, wouldn't it work to just use various methods (FTP, SFTP, file upload functions built into various Linux panels, etc.) to upload the zip package directly to the corresponding location and then unzip it? What more could you ask for?

However, the reason this method is left for last is that it feels a bit ungraceful: it lacks the back-and-forth feeling of meeting a challenge head-on (like Tang Bohu and Dui Chuan Chang), and feels more like flipping the table when you can't win. Furthermore, this method is not suitable for certain WordPress deployment methods, such as WordPress deployed on shared hosting.

However, overall, this should be considered the most effective method besides modifying “.htaccess”. Therefore, after weighing the options, I still included this solution; please use it at your discretion.

Summary

Currently, for WordPress deployed via Docker, modifying the ”.htaccess” file in the root directory of the mounted folder (the typical path is ”wordpress/html/” on the host machine) to bypass the upload file size limit is the most convenient method (I have always disliked the practice of modifying files directly inside Docker). Of course, this is also suitable for scenarios where WordPress is deployed using Apache from source.

Other than that, there is the direct upload method. There is not much to say about this; anyone with the corresponding permissions for the WordPress host can use it.

As for the method of directly modifying php.ini, it depends on your actual environment. If you are deploying from source, are the host administrator, and don't mind the scope of the impact, then this is also a simple approach.

As for modifying the theme's functions.php and using dedicated plugins, for those who find it inconvenient or do not want to modify ”.htaccess” and ”php.ini” right off the bat, these are at least methods that can be tried first: if they work, great; if not, there are still fallback options available.

View Related Categories · 3 Matches
📌 Content Structure Prompt:
This content is part of the following knowledge map, where you can view the complete content path: WordPress Learning Roadmap。
📎 Related Articles
Share this article
The blog content is original, please indicate the source when reposting! The RSS address of the blog is:https://blog.tangwudi.com/feed, welcome to subscribe; if needed, you can join theTelegram Groupto discuss questions together.
No Comments

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗ
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
Kaomoji
Emoji
Little Dinosaur
Flower!
Previous
Next
       

👋 Welcome to “Wudi's Personal Blog”

Here, long-term exploration is mainly carried out around the following directions:

🧱 Personal Digital Infrastructure and Blog System Construction
☁️ Cloudflare and Network Architecture Practice
🧠 AI and Knowledge System Exploration
🛡️ Network Security and Access Optimization
🎵 Music and Sound Cognition
👁️ Cognitive Perspectives and Worldviews