php - method="post" enctype="text/plain" are not compatible? -
when use
<form method="post" enctype="text/plain" action="proc.php">
form data can not sent proc.php file properly. why? problem? why can't use text/plain encoding post can use method?
[revised]
the answer is, because php doesn't handle (and not bug):
https://bugs.php.net/bug.php?id=33741
valid values enctype in <form> tag are: application/x-www-form-urlencoded multipart/form-data
the first default, second 1 need when upload files.
@alohci provided explanation why php doesn't populate $_post
array, store value inside variable $http_raw_post_data
.
example of can go wrong text/plain
enctype:
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>
file2.php:
<?php print($http_raw_post_data); ?>
result:
input1=abc input2=def input2=ghi
no way distinguish value of input1
, input2
variables. can be
- input1=
abc\r\ninput2=def
, input2=ghi
, as - input1=
abc
, input2=def\r\ninput2=ghi
no such problem when using other 2 encodings mentioned before.
the difference between , post:
- in get, variables part of url , present in url query string, therefore must url-encoded (and are, if write
enctype="text/plain"
- gets ignored browser; can test using wireshark sniff request packets), - when sending post, variables not part of url, sent last header in http request (postdata), , can choose whether want send them
text/plain
orapplication/x-www-form-urlencoded
, second 1 non-ambiguous solution.
Comments
Post a Comment