23

我想知道是否有人知道全局帖子的总长度。例如:

$_POST['formInput'] = "hello world, how long can i be?";

我正在创建一个网站,有人将在其中输入未知数量的字符到 textarea 中,因此它可能是 word 文档上的 2 页。那么,如果有人知道除了使用全局后我可以如何做到这一点的任何其他方法吗?(它不能保存在文件中,因为它的重要数据我不希望其他人找到)这将非常有帮助。

谢谢

4

4 回答 4

27

Check your php.ini for post_max_size. This is typically about 8mb by default, but if you're on shared-hosting, it could definitely vary.

; Maximum size of POST data that PHP will accept.
post_max_size = 8M

You'll have to use $_POST if you wish to send large amounts of data to the server. For further study, I'd suggest checking out POST Method Uploads in the documentation.

于 2010-02-16T22:14:58.340 回答
7

$_POST is populated from the body of a HTTP-request. Since there are no restrictions on the size of a HTTP-request, there are no restrictions in the protocol layer. However PHP has some limitations on how much input it will read. You can control this with the ini-setting post_max_size

于 2010-02-16T22:16:13.953 回答
4

另一个问题可能是 php.ini 中指令 max_input_vars 的默认限制(默认为 1000),而不仅仅是 post_max_size。例如,如果您有一个包含数千个复选框的非常大的表单,则 $_POST 数组将只有 1000 个键。

于 2013-11-19T14:50:01.120 回答
1

If you want some large amount of data sent from the browser to the server, you'll have to use HTTP POST method -- which means the data will be received, on the PHP side, in the $_POST superglobal array ; there's not much you can do about that.

The configuration directive post_max_size defines the maximum amount of data that can be received using the POST method -- you might need to set that to a value higher than the default one, depending on your needs.

And, as said on the documentation of post_max_size, the value set for memory_limit can also have its importance.

于 2010-02-16T22:16:44.403 回答