preface

The encType attribute specifies how form data should be encoded before being sent to the server.

By default, form data will be coded as “Application/X-www-form-urlencoded”. That is, all characters are encoded (Spaces converted to “+” plus signs, special symbols converted to ASCII HEX values) before being sent to the server

value describe
application/x-www-form-urlencoded Encodes all characters before sending (default)
multipart/form-data No character encoding. You must use this value when using forms that contain file upload controls
application/json Serves as the request header to tell the server that the message body is a serialized JSON string. Except for the lower version of IE, basically all support.
text/plain Spaces are converted to “+” plus signs, but no special character encoding.

application/x-www-form-urlencoded

<form action="http://localhost:8888/task/" method="POST">
    First name: <input type="text" name="firstName" value="Mickey&"><br>
    Last name: <input type="text" name="lastName" value="Mouse "><br>
    <input type="submit" value="Submit">
</form>
Copy the code

application/form-data

<form action="http://localhost:8888/task/" method="POST" enctype="multipart/form-data">
    First name: <input type="text" name="firstName" value="Mickey&"><br>
    Last name: <input type="text" name="lastName" value="Mouse "><br>
    <input type="submit" value="Submit">
</form>
Copy the code

It can be seen that multipart/form-data does not encode parameters and uses boundary equivalent to &. The value of boundary is —-Web**AJv3

reference

Four common ways to POST data

There are four common ways to submit data through POST