Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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 cant be saved in a file, as its important data that i dont want other people to find) That would be very helpful.

Thanks

like image 506
phpNutt Avatar asked Feb 16 '10 22:02

phpNutt


People also ask

What is the default maximum size of post in PHP INI of?

The default PHP values are 2 MB for upload_max_filesize, and 8 MB for post_max_size.

Is $_ POST a global variable?

To receive a POST request in PHP, we will need to use the $_POST super global variable. Since it is a global variable, you can use the $_POST variable in any scope. The $_POST super global variable is an associative array of variables containing POST request data sent to the script.

What is the difference between the $_ GET and $_ POST Super global variables?

Difference is: $_GET retrieves variables from the querystring, or your URL.> $_POST retrieves variables from a POST method, such as (generally) forms.

What is $_ Global in PHP?

$GLOBALS is a PHP super global variable which is used to access global variables from anywhere in the PHP script (also from within functions or methods). PHP stores all global variables in an array called $GLOBALS[index]. The index holds the name of the variable.


2 Answers

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.

like image 199
Sampson Avatar answered Sep 22 '22 14:09

Sampson


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

like image 29
troelskn Avatar answered Sep 19 '22 14:09

troelskn