在 PHP 中上传最大大小?

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

Upload max size in PHP?

phpiniuploading

提问by sri

Is it possible for the upload of ~100 MB files using PHP?

是否可以使用 PHP 上传约 100 MB 的文件?

If so, what changes need to occur in the configuration file (php.ini)?

如果是这样,配置文件 ( php.ini) 中需要进行哪些更改?

Sri

斯里

回答by Pekka

The following options are relevant:

以下选项是相关的:

and possibly

并且可能

回答by miku

In your php.iniadjust the value of:

在您的php.ini调整值中:

file_uploads = On
upload_max_filesize = 100M //needs to be in {x}M format

And allow larger post size:

并允许更大的帖子尺寸:

post_max_size = 100M

回答by Torstein

To allow for larger uploads with PHP you must change a few settings in the php.ini file (upload_max_filesize, max_input_time, memory_limit, max_execution_time, post_max_size). You can find your php.ini file under you PHP installation directory, and more information about the required settings here.

要允许使用 PHP 进行更大的上传,您必须更改 php.ini 文件中的一些设置(upload_max_filesize、max_input_time、memory_limit、max_execution_time、post_max_size)。您可以在 PHP 安装目录下找到 php.ini 文件,有关所需设置的更多信息请点击此处

回答by Marius Hansen

This dumfounded me for a while so just wanted to add:

这让我目瞪口呆了一段时间,所以只想补充:

If your project alsouse nginx(e.g. a buildpack), you may have to add client_max_body_size 100M;to your nginx.conffile since nginx defaults to only 1M(1 MB) - in addition to the PHP settings mentioned above.

如果您的项目使用nginx(例如 buildpack),您可能需要添加client_max_body_size 100M;到您的nginx.conf文件中,因为 nginx 默认仅为1M(1 MB) - 除了上面提到的 PHP 设置。

Regarding PHP settings, I create a .user.inifile at root level of my projects to change the few settings I want to override from the default php.inifile.

关于 PHP 设置,我.user.ini在项目的根级别创建了一个文件,以更改我想从默认php.ini文件中覆盖的少数设置。

In my setup (using dokku) it was located at /etc/nginx/nginx.conf, then added the extra line via nano nginx.conf. I don't directlyuse nginx, but my buildpack adds it.

在我的设置中(使用dokku)它位于/etc/nginx/nginx.conf,然后通过nano nginx.conf. 我不直接使用 nginx,但我的 buildpack 添加了它。

Hope this helps someone :)

希望这对某人有所帮助:)

回答by spinon

You just need to change the timeout of the server and the max file size in the php.ini file.

您只需要更改服务器的超时时间和 php.ini 文件中的最大文件大小。

http://blog.jc21.com/2007-05-03/change-the-maximum-upload-size-with-php/

http://blog.jc21.com/2007-05-03/change-the-maximum-upload-size-with-php/

EDIT: You may not need to change the timeout of the server as that really would depend on which server you are running things on.

编辑:您可能不需要更改服务器的超时,因为这实际上取决于您正在运行的服务器。