更改 Laravel 中的 php.ini 设置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38991424/
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:46:51  来源:igfitidea点击:

Change php.ini setting in laravel

phplaravel

提问by Mohammad Reza

HI I want to change some of php.ini setting like post_max_sizeand upload_max_filesizeI ran php.info() and found the correct php.ini file I changed it and reset the wamp then I ran php.info() again and I saw that the setting wasn't applied ,so how can I change php.ini setting in laravel? P.S: I wanted to upload a large file in laravel and I ran in to this problem

HI我想改变一些php.ini中的像post_max_sizeupload_max_filesize我又跑php.info(),并找到了正确的php.ini文件我改变了它,并重置WAMP然后我跑php.info()和我看到的设置没有应用,那么如何更改 Laravel 中的 php.ini 设置?PS:我想在laravel中上传一个大文件,我遇到了这个问题

回答by RiggsFolly

There are 2 mistakes people make when amending the php.inifile in WAMPServer

人们php.ini在 WAMPServer 中修改文件时会犯两个错误

Updating the wrong file.

更新错误的文件。

See this post for a correct method of editing the right file

有关编辑正确文件的正确方法,请参阅此帖子

Editing the wrong piece of the php.inifile

编辑错误的php.ini文件部分

At the top of the file are a lot of comments intended to help people understand what most of the parameters do. Do not edit these comments. Instead search again for the parameter you want to change it should appear again later in the file.

文件顶部有很多注释,旨在帮助人们了解大多数参数的作用。不要编辑这些评论。而是再次搜索要更改的参数,它应该稍后再次出现在文件中。

post_max_size = 8M

Is on line 660 (or there abouts depending on version)

在线 660(或根据版本而定)

upload_max_filesize = "16M"

Is on line 810 (or there abouts depending on version)

在线 810(或根据版本而定)

Final Note: Remember that the post_max_sizemust be > that the upload_max_filesizebecause the uploaded files are part of the POST payload but you need to include space in the post_max_sizefor the other fields on a form as well as the file(s)

最后注意:请记住,post_max_size必须 >upload_max_filesize因为上传的文件是 POST 有效负载的一部分,但您需要post_max_size在表单的其他字段以及文件中包含空格

Additional checks

额外检查

If the above is not the issue then :-

如果以上不是问题,那么:-

Do you have a php.ini in the wrong place. Check your boot drive for any other php.ini file. There shoud be no php.inifiles outside the \wamp\folder. There is lots af bad advice out there and some suggest to put the php.ini file in the \windowsor \windows\system32folders. If you find any other delete them.

您是否在错误的位置放置了 php.ini。检查您的启动驱动器是否有任何其他 php.ini 文件。php.ini文件\wamp\夹外应该没有文件。那里有很多不好的建议,有些建议将 php.ini 文件放在\windows\windows\system32文件夹中。如果你发现任何其他删除它们。

There is also bad advice out there suggesting that you add the PHP folder to your system PATH. If you have anything to do with WAMPServer on your PATH remove it.

还有一些不好的建议建议您将 PHP 文件夹添加到系统路径中。如果您与 PATH 上的 WAMPServer 有任何关系,请将其删除。