PHP: whats the total length of a post global variable?

前端 未结 4 976
Happy的楠姐
Happy的楠姐 2020-12-03 04:45

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?\";
相关标签:
4条回答
  • 2020-12-03 05:29

    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.

    0 讨论(0)
  • 2020-12-03 05:40

    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.

    0 讨论(0)
  • 2020-12-03 05:43

    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.

    0 讨论(0)
  • 2020-12-03 05:47

    $_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

    0 讨论(0)
提交回复
热议问题