Analysis on the Difference between application and x www form urlencoded and multipart and form data

  • 2021-07-02 23:44:48
  • OfStack

In the syntax of the Form element, EncType indicates the format of the submitted data

Use the Enctype property to specify the encoding type used by the browser when posting data back to the server.

Here is the explanation:

application/x-www-form-urlencoded: Form data is encoded as name/value pairs. This is the standard encoding format.

multipart/form-data: Form data is encoded as one message, and each control on the page corresponds to one part of the message.

text/plain: Form data is encoded in plain text without any control or format characters.

Supplement

The enctype attribute of form is encoding mode, which is commonly used in two ways: application/x-www-form-urlencoded and multipart/form-data, and the default is application/x-www-form-urlencoded.

When action is get, the browser uses x-www-form-urlencoded to convert form data into a string (name1=value1) & name2=value2...), and then load the new url by splitting the string append after url.

When action is post, the browser encapsulates form data into http body and sends it to server.

If there is no control for type=file, use the default application/x-www-form-urlencoded.

However, if there is type=file, multipart/form-data will be used. The browser will divide the whole form into controls, and add Content-Disposition (form-data or file), Content-Type (default is text/plain), name (control name) and other information to each part, and add separators (boundary).


Related articles: