When I use
<form method="post" enctype="text/plain" action="proc.php">
form data can not be sent to proc.php file properly. Why? What is the problem? Why I can’t use text/plain encoding with post but I can use it with get method?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
[Revised]
The answer is, because PHP doesn’t handle it (and it is not a bug):
https://bugs.php.net/bug.php?id=33741
The first is the default, the second one you need only when you upload files.
@Alohci provided explanation why PHP doesn’t populate
$_POSTarray, but store the value inside a variable$HTTP_RAW_POST_DATA.Example of what can go wrong with
text/plainenctype:file1.php:
file2.php:
Result:
No way to distinguish what is the value of
input1andinput2variables. It can beabc\r\ninput2=def, input2=ghi, as well asabc, input2=def\r\ninput2=ghiNo such problem when using the other two encodings mentioned before.
The difference between GET and POST:
enctype="text/plain"– it just gets ignored by the browser; you can test it using Wireshark to sniff the request packets),text/plainorapplication/x-www-form-urlencoded, but the second one is the only non-ambiguous solution.