Why is "method="post" enctype="text/plain"" not compatible?
When using the HTML form encoding method "post" with "enctype="text/plain"," form data fails to be delivered to the PHP script. What is the reason behind this issue? Why is text/plain encoding incompatible with post while it is allowed with get?
Explanation
PHP does not support "enctype="text/plain"" for "method="post"; it is not a program bug.
Approved values for "enctype" in a form are:
The first option is the default, while the second is essential for file uploads.
PHP does not populate the $_POST array when "enctype="text/plain"" is used; instead, it stores the value in $HTTP_RAW_POST_DATA.
Potential Issues with Text/Plain Encoding
Consider the following scenario:
In file1.php:
<form method="post" enctype="text/plain" action="file2.php"> <textarea name="input1">abc input2=def</textarea> <input name="input2" value="ghi" /> <input type="submit"> </form>
In file2.php:
<?php print($HTTP_RAW_POST_DATA); ?>
The expected result:
input1=abc input2=def input2=ghi
However, with text/plain encoding, there is no way to distinguish the values of input1 and input2. The result could be:
The difference between GET and POST is that:
The above is the detailed content of Why is `enctype='text/plain'` incompatible with the POST method in HTML forms?. For more information, please follow other related articles on the PHP Chinese website!