php 7 php.ini upload_max_filesize 不工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37381522/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 01:12:52  来源:igfitidea点击:

php 7 php.ini upload_max_filesize not working

phpphp-7

提问by CuongDC

I have read many solutions on internet , but still cannot change upload_max_filesizevalue (upload_max_filesizealways = 2M )

我在互联网上阅读了许多解决方案,但仍然无法更改upload_max_filesize值(upload_max_filesize始终 = 2M)

here is my loaded php.iniin phpinfo():

这是我加载php.iniphpinfo()

Configuration File (php.ini) Path         /etc/php/7.0/apache2
Loaded Configuration File                    /etc/php/7.0/apache2/php.ini
Scan this dir for additional .ini files      /etc/php/7.0/apache2/conf.d 
upload_max_filesize 2M  2M
post_max_size   8M  8M

here is my edited php.iniin /etc/php/7.0/apache2/php.ini

这是我编辑php.ini/etc/php/7.0/apache2/php.ini

; http://php.net/post-max-size
post_max_size = 86M
; http://php.net/upload-max-filesize
upload_max_filesize = 40M

im using ubuntu 14.04,apache2,php7.0 (I have reset apache2 many time after each change in php.ini )

我使用的是 ubuntu 14.04,apache2,php7.0(每次更改 php.ini 后我都多次重置 apache2)

采纳答案by CuongDC

i fingured out !

我发现了!

in my loaded php.iniconfig , my error_reportingvalues is E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED-> this is wrong!, so i changed it to

在我加载的php.ini配置中,我的error_reporting值是E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED-> 这是错误的!,所以我将其更改为

error_reporting: E_ALLand then restart apache2 server, now everything working fine !

error_reporting: E_ALL然后重新启动 apache2 服务器,现在一切正常!



so please note : if php.inihave any error , it will use default value (which means upload_max_filesizealways 2M)

所以请注意:如果php.ini有任何错误,它将使用默认值(这意味着upload_max_filesize总是2M

回答by Sandy

I had a fix for PHP-FPM 7.1

我修复了 PHP-FPM 7.1

Edit your php.ini in

编辑你的 php.ini

/etc/php/7.1/fpm/php.ini

/etc/php/7.1/fpm/php.ini

Make changes to whatever option you want like, post_max_size, upload_max_filesize, max_execution_time & so...

更改您想要的任何选项,post_max_size、upload_max_filesize、max_execution_time 等等...

save & close file.

保存并关闭文件。

run

sudo service php7.1-fpm restart

须藤服务 php7.1-fpm 重启

It will work!

它会起作用!

回答by Info Loopgraaf

I had an other fix for it. os: ubuntu 16.04 phpversion: 7.0

我有一个其他的修复方法。操作系统:ubuntu 16.04 phpversion:7.0

I created a phpinfo.phpfile containing:

我创建了一个phpinfo.php文件,其中包含:

<?php phpinfo() ?>

place the phpinfo.php file in the root of your website www.mywebsite.com/phpinfo.php

将 phpinfo.php 文件放在您网站的根目录 www.mywebsite.com/phpinfo.php

Navigating to it and lookup the line:

导航到它并查找该行:

Loaded Configuration File : /etc/php/7.0/cgi/php.ini

加载的配置文件:/etc/php/7.0/cgi/php.ini

Now you know what php.ini file is loaded.

现在您知道加载了什么 php.ini 文件。

ssh into the server and use your favorite editing tool (mine is nano) to adjust the php.ini

ssh 进入服务器并使用您最喜欢的编辑工具(我的是 nano)来调整 php.ini

change the values to meet your preferences.

更改值以满足您的偏好。

post_max_size = 128M

post_max_size = 128M

upload_max_filesize = 64M

upload_max_filesize = 64M

Save and close the file.

保存并关闭文件。

Restart apache

重启apache

sudo service apache2 restart

__

__

check the phpinfo.ini if the new values are as set.

如果新值已设置,请检查 phpinfo.ini。

and if they do you are set to go.

如果他们这样做了,你就可以走了。

回答by Joel Jerushan

For php7.2-fpm

为了 php7.2-fpm

Ubuntu php-fpmlocated at /etc/php/7.2/fpmso

Ubuntu的php-fpm位于/etc/php/7.2/fpm这样

  1. cd /etc/php/7.2/fpm
  2. sudo nano php.ini
  3. Search for post_max_size = 512Mand add your fav size that you really needed
  4. Search for upload_max_filesize = 512Mand add your fav size that you really needed
  5. Save File
  6. And Last DO NOT FORGET TO RESTART PHP7.2-FPM to restart sudo service php7.2-fpm restart
  1. cd /etc/php/7.2/fpm
  2. sudo nano php.ini
  3. 搜索post_max_size = 512M并添加您真正需要的最喜欢的尺码
  4. 搜索upload_max_filesize = 512M并添加您真正需要的最喜欢的尺码
  5. 保存存档
  6. 最后不要忘记重启 PHP7.2-FPM 重启 sudo service php7.2-fpm restart

Thats all!

就这样!

回答by rkhff

I also found that restarting the httpd service didn't pick up changes in the loaded configuration file (/etc/php.inion Fedora 29). It's worth listing all systemd units and doing a grep for the string "php":

我还发现重新启动 httpd 服务并没有发现加载的配置文件(/etc/php.ini在 Fedora 29 上)中的更改。列出所有 systemd 单元并为字符串“php”做一个 grep 是值得的:

# systemctl list-unit-files | grep php
php-fpm.service

Restarting php-fpm did the trick for me:

重新启动 php-fpm 对我有用:

# systemctl restart php-fpm

回答by Serhat Soruklu

Most people are forgetting to restart their php via the terminal that's why it isn't working, if you think you've done everything correctly be sure to restart your php & the server.

大多数人都忘记通过终端重新启动他们的 php,这就是它不起作用的原因,如果您认为自己已经正确完成了所有操作,请务必重新启动您的 php 和服务器。

回答by Rakshitha Muranga Rodrigo

Yeah, Actually I forgot to restart correctly.

是的,其实我忘了正确重启。

sudo service apache2 restartis not enough

sudo service apache2 重启是不够的

first add the configurations to /etc/php/7.1/fpm/php.iniand to /etc/php/7.1/cli/php.ini
#/php/ - then your php version here instead "7.1"ACtually one of these configuration file is the active one (if you want to see what use <?php phpinfo() ?>command in indextest.phpfile and check it on browser) Then change these parameters on each file with what you want:

首先将配置添加到/etc/php/7.1/fpm/php.ini/etc/php/7.1/cli/php.ini
#/php/ - 然后你的php版本在这里而不是“7.1”实际上是这些配置之一文件是活动的(如果您想查看indextest.php文件中的use<?php phpinfo() ?>命令并在浏览器上检查它)然后使用您想要的更改每个文件上的这些参数:

post_max_size = 512M
upload_max_filesize = 512M

And then use following command to restart the php server:

然后使用以下命令重新启动php服务器:

sudo service php7.0-fpm restart #php<then your php version here> instead "7.0"

or

或者

sudo /etc/init.d/php7.1-fpm restart  #php<then your php version here> instead "7.1"

Now you should be able to see the changes of upload size. Cheers !

现在您应该能够看到上传大小的变化。干杯!

as shown in hereyou can get to know more about the php server controlls :

如图这里你可以了解更多关于PHP服务器controlls:

$ sudo service php7.0-fpmstart # <- restart it
$ sudo service php7.0-fpm stop # <- restart it
$ sudo service php7.0-fpm restart # <- restart it
$ sudo service php7.0-fpm reload # <- reload it

回答by Ali

I am using Nginx and my solution was to restart php-fpm.

我正在使用 Nginx,我的解决方案是重新启动 php-fpm。

Restarting Nginx didn't do anything.

重新启动 Nginx 没有做任何事情。

sudo service php7.2-fpm restart

回答by dcima

After spending hours reading forum I've resolved this way:

在花了几个小时阅读论坛后,我已经解决了这个问题:

cd /etc/php
find . -name "*.ini" | xargs grep -il upload_max_filesize
./7.1/apache2/php.ini
./7.1/mods-available/better.ini
./7.1/cgi/php.ini
./7.1/cli/php.ini
./7.1/phpdbg/php.ini
./7.1/fpm/conf.d/20-better.ini
./7.1/fpm/php.ini
./7.1/embed/php.ini

change upload_max_filesize in ./7.1/fpm/conf.d/20-better.inithen

更改./7.1/fpm/conf.d/20-better.ini 中的upload_max_filesize然后

/etc/init.d/php7.1-fpm restart

now phpinfo reports: upload_max_filesize 10G 10G

现在 phpinfo 报告:upload_max_filesize 10G 10G

Hope this helps.

希望这可以帮助。

回答by Ali Ghalambaz

i also had this problem!

我也有这个问题!

if you are using php-fpm service need to find php-fpm.conf and add line

如果你使用 php-fpm 服务需要找到 php-fpm.conf 并添加一行

php_admin_value[upload_max_filesize] = 100M

php_admin_value[upload_max_filesize] = 100M

for changing other type of values

用于更改其他类型的值

#just for example
php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on