Search code examples
phppostglobal-variablesstring-length

PHP: what's the total length of a $_POST global variable?


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


Solution

  • 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.