is application/x-www-form-urlencoded default for html form?
Asked Answered
K

3

45

I found out that HTML form supports only two enctype types. They are application/x-www-form-urlencoded and multipart/form-data. I understand that I use multipart/form-data when I need to upload a file. When do I use application/x-www-form-urlencoded? Is it default form enctype?

Knighthead answered 13/3, 2010 at 0:25 Comment(1)
Actually three: it also supports text/plain.Compulsory
B
59

Yes, it is. Here's a cite from the W3 HTML forms specification:

The default value for this attribute is "application/x-www-form-urlencoded". The value "multipart/form-data" should be used in combination with the INPUT element, type="file".

The webbrowser will take care about URL encoding automatically.

Breach answered 13/3, 2010 at 0:28 Comment(0)
W
9

application/x-www-form-urlencoded

This is the default content type. Forms submitted with this content type must be encoded as follows:

1) Control names and values are escaped. Space characters are replaced by '+', and then reserved characters are escaped as described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by '%HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e., `%0D%0A').

2) The control names/values are listed in the order they appear in the document. The name is separated from the value by '=' and name/value pairs are separated from each other by `&'.

Check out this link for more on form content types, or here for more information about file uploads and such.

Wilt answered 13/3, 2010 at 0:30 Comment(0)
D
2

Yes, the default enctype is application/x-www-form-urlencoded.

Decamp answered 13/3, 2010 at 0:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.