We know that it is best to set the request header to specify the applicationx-www-form-urlencoded encoding type when sending an AJAX request to the server through POST. You must specify the encoding type as & quot; multipartform-data & quot; when uploading files through a form ;. In the Form element syntax, EncType indicates the format of the submitted data.
Use the Enctype attribute to specify the encoding type used by the browser when data is sent back to the server.
Below is the description:
Application/x-www-form-urlencoded: form data is encoded as name/value pairs. This is the standard encoding format.
Multipart/form-data: The form data is encoded as a message. each control on the page corresponds to a part of the message.
Text/plain: the form data is encoded in plain text format, which does not contain any controls or format characters.
Supplement
The enctype attribute of form is encoded in two ways: application/x-www-form-urlencoded and multipart/form-data, the default value is application/x-www-form-urlencoded.
When the action is get, the browser uses the x-www-form-urlencoded encoding method to convert form data into a string (name1 = value1 & name2 = value2 ...), then append the string to the end of the url, using? Load the new url.
When the action is post, the browser encapsulates form data into the http body and sends it to the server.
If there is no type = file control, use the default application/x-www-form-urlencoded.
However, if type = file exists, you need to use multipart/form-data. The browser splits the entire form into controls and adds Content-Disposition (form-data or file) and Content-Type (text/plain by default) to each part), name (control name) and other information, plus the delimiter (boundary ).