简体   繁体   English

WordPress忽略php.ini上传最大文件大小

[英]WordPress ignoring php.ini upload max file size

I'm running a WordPress site (not MU), I have set upload_max_filesize = 50M, post_max_size=50M in php.ini.我正在运行一个 WordPress 网站(不是 MU),我在 php.ini 中设置了 upload_max_filesize = 50M,post_max_size=50M。 The results of phpinfo() function show the value to be 50M but in WordPress Media uploader Max upload file size is still 32M. phpinfo() 函数的结果显示值为 50M,但在 WordPress 媒体上传器中,最大上传文件大小仍为 32M。

I have also tried to write this code in the theme's functions.php:我也尝试在主题的functions.php中编写此代码:

@ini_set( 'upload_max_size' , '50M' ); @ini_set( 'upload_max_size' , '50M' );
@ini_set( 'post_max_size', '50M'); @ini_set('post_max_size', '50M');

Also tried deactivating all plugins, changed theme but no resort, WordPress still says 32 Mb.还尝试停用所有插件,更改主题但没有办法,WordPress 仍然说 32 Mb。

Can anyone guide me what can be wrong here?谁能指导我这里有什么问题?

There are many ways to achieve what you need , here are three ways you can use any one of these有很多方法可以实现您所需要的,这里有三种方法您可以使用其中任何一种

1) Using functions file: Copy and paste the code below to functions.php file 1)使用函数文件:将下面的代码复制并粘贴到functions.php文件中

@ini_set( 'upload_max_filesize' , '50M' );
@ini_set( 'post_max_size', '50M');
@ini_set( 'max_execution_time', '300' );

2) Try using htaccess method by adding the code below: 2)通过添加以下代码尝试使用htaccess方法:

php_value upload_max_filesize 50M
php_value post_max_size 50M
php_value max_execution_time 300
php_value max_input_time 300

3) Last method, php.ini file that you are already trying 3)最后一种方法,你已经在尝试的 php.ini 文件

upload_max_filesize = 50M
post_max_size = 50M
max_execution_time = 300

Hope it helps !希望能帮助到你 !

I had the same problem, and the other answers didn't completely work for me, and I'm apparently not alone, so here's what I did to make it work.我遇到了同样的问题,其他答案对我来说并不完全有效,而且我显然并不孤单,所以这就是我为使其发挥作用所做的工作。

  1. Locate your php.ini files: sudo find / -name "php*.ini" -print.找到您的 php.ini 文件:sudo find / -name "php*.ini" -print。 This will give you an idea of where any configuration files might be hiding.这将使您了解任何配置文件可能隐藏的位置。
  2. Open them one at a time (you may need sudo).一次打开一个(您可能需要 sudo)。
  3. Check to see if they have a line "upload_max_filesize=##" where ## is some value (ie 250M).检查他们是否有一行“upload_max_filesize=##”,其中## 是某个值(即250M)。 You shouldn't have to add any of the lines.您不必添加任何行。 This should already be in the file.这应该已经在文件中。
  4. You will need to change the line "post_max_size=##" to be greater than or equal to upload_max_filesize.您需要将“post_max_size=##”行更改为大于或等于upload_max_filesize。

Notes:笔记:

Supposedly, you can do "php -i | grep php.ini" to see which configuration file is being used, but changing the indicated file did not work for me.假设您可以执行“php -i | grep php.ini”来查看正在使用哪个配置文件,但是更改指示的文件对我不起作用。 I changed one that lived at /etc/php5/apache2/php.ini to make it work.我更改了一个位于 /etc/php5/apache2/php.ini 的文件以使其正常工作。 Some trial and error will be needed, but give this a shot.将需要一些试验和错误,但试一试。

There are a lot of people having this problem the best way to fix it is by creating a new php.ini inside your wp-admin folder.有很多人遇到这个问题,最好的解决方法是在你的 wp-admin 文件夹中创建一个新的 php.ini。

1.Connect to your site via FTP or File Manager 2.Navigate to wp-admin folder 3.Create a file inside the wp-admin folder called php.ini 4.Add in this line: max_input_vars = 5000 5.Save 1.通过 FTP 或文件管理器连接到您的站点 2.导航到 wp-admin 文件夹 3.在 wp-admin 文件夹中创建一个名为 php.ini 的文件 4.在此行中添加:max_input_vars = 5000 5.保存

I wrote a quick blog article on it here too: Increasing Your Max_input_vars Value我也在这里写了一篇关于它的快速博客文章: 增加你的 Max_input_vars 值

This was absolute insanity.这绝对是疯了。 I almost went crazy looking for a solution.我几乎疯狂地寻找解决方案。

My wp-admin/php.ini was getting completely ignored.我的wp-admin/php.ini被完全忽略了。
I changed /etc/apache2/php/7.4/cli/php.ini , still nothing, it was getting ignored.我更改了/etc/apache2/php/7.4/cli/php.ini ,仍然没有,它被忽略了。
Turns out it was getting settings from /etc/php/7.4/apache2/php.ini .原来它是从/etc/php/7.4/apache2/php.ini获取设置。

In case you're using multisite keep in mind that there is a max_upload_filesize setting for the network.如果您使用多站点,请记住网络有一个 max_upload_filesize 设置。

WordPress 多站点设置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM