PHP:$_POST 全局变量的总长度是多少?
我想知道是否有人知道全球邮政的总长度。例如:
$_POST['formInput'] = "hello world, how long can I be?";
我正在创建一个网站,有人会在 textarea
中输入未知数量的字符,因此可能是一个 Word 文档的 2 页。
因此,如果有人知道除了使用 $_POST
全局之外的任何其他方法(它不能保存在文件中,因为它是我不希望其他的重要数据)找到的人) - 这将非常有帮助。
谢谢
I was wondering if anybody knows the total length that a post global could be. e.g:
$_POST['formInput'] = "hello world, how long can I be?";
I am creating a site where someone will enter an unknown amount of chars into a textarea
, so potentially it could be 2 pages on a word document.
So if anybody knows of any other methods of how I can do this apart from using a $_POST
global (it can't be saved in a file, as it's important data that I don't want other people to find) - that would be very helpful.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
检查 php.ini 中的
post_max_size
。默认情况下,这通常约为 8mb,但如果您使用共享主机,则它肯定会有所不同。如果您希望向服务器发送大量数据,则必须使用
$_POST
。为了进一步研究,我建议查看 POST 方法上传文档中的。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.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.$_POST
由 HTTP 请求的正文填充。由于 HTTP 请求的大小没有限制,因此协议层也没有限制。然而,PHP 对于读取的输入量有一些限制。您可以使用 ini 设置post_max_size 来控制它
$_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-settingpost_max_size
另一个问题可能是 php.ini 中指令 max_input_vars 的默认限制(默认 1000),而不仅仅是 post_max_size。例如,如果您有一个非常大的表单,其中包含数千个复选框,则 $_POST 数组将只有 1000 个键。
Another problem can be the default limit in php.ini for directive max_input_vars (default 1000), not only the post_max_size. If you have e.g. a very large form with thousands of checkboxes the $_POST array will have only 1000 keys.
如果您希望从浏览器向服务器发送大量数据,则必须使用 HTTP POST 方法 - 这意味着 PHP 端将在
$_POST
超全局数组;对此你无能为力。配置指令
post_max_size
< /a> 定义使用 POST 方法可以接收的最大数据量 - 您可能需要将其设置为高于默认值的值,具体取决于您的需要。并且,正如
post_max_size
的文档中所述,为memory_limit
也有其重要性。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 formemory_limit
can also have its importance.