PHP post_max_size与upload_max_filesize的区别是什么? [英] PHP post_max_size vs upload_max_filesize, what is the difference?

查看:96
本文介绍了PHP post_max_size与upload_max_filesize的区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试通过为此创建的管理区上传15mb的PDF文件时,没有任何反应.没有成功或错误消息,但是PDF没有上传.

When trying to upload a PDF file that was 15mb through an admin area created for doing so, nothing happened. There was no success or error message, but the PDF did not upload.

然后我认为php.ini设置可能有问题.果然,当我查看该文件时,发现限制设置为8m.我假设这意味着8mb.

I then thought that it could be an issue with the php.ini settings. Sure enough, when I looked at the file, I found that the limits were set to 8m. Which I'm assuming means 8mb.

post_max_size: http://php.net/post-max-size

; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
post_max_size = 20M

upload_max_filesize : http://php.net/upload-max-filesize

; Maximum allowed size for uploaded files.
upload_max_filesize = 20M

查看注释,似乎其中一个是用于上载的文件,而另一个则与POST数据直接相关.我对此情况感到困惑的是:如果您有一个将POST图像复制到另一页的表单,那么upload_max_filesizepost_max_size算什么?两者都属于吗?请问优先吗?在某些情况下会使用一种而不是另一种吗?

Looking at the comments, it appears that one is for files being uploaded, while the other relates directly to POST data. What I'm confused about is this scenario: If you have a form that is POST'ing an image to another page, what does that count as, upload_max_filesize or post_max_size? Does it fall under both? Does one take precedence? Are there cases where one would be used and not the other?

因此,如果我有一个包含3个文件输入的表单,所有文件都允许20mb或更小,则设置必须像这样设置:

So if I have a form that has 3 file inputs, all allowing files 20mb or smaller, the settings would have to be set like so:

upload_max_filesize = 20M
post_max_size = 60M

推荐答案

您是正确的. post_max_size是所有POST正文数据的最大大小.不管是POST JSON还是DVD集合,这都是POST正文数据.您的文件上传计入此限制.您还应该注意,如果要上传多个文件,则文件总大小必须在此限制之内.

You are correct. post_max_size is the maximum size for all POST body data. It doesn't matter if you're POSTing JSON or your DVD collection, this is all POST body data. Your file upload counts towards this limit. You should also be aware that if you are uploading multiple files, the total file size has to fit within this limit.

upload_max_filesize是仅用于POST文件的最大大小.其他类型的POST正文数据不受此限制.

upload_max_filesize is a maximum size only for files that are POSTed. Other types of POST body data are not subject to this limit.

简而言之,如果要上传大文件,则必须同时增加两个限制.

In short, if you want to upload large files, you must increase both limits.

这篇关于PHP post_max_size与upload_max_filesize的区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆