What is the default enctype for an HTML form?

好久不见. 提交于 2020-07-19 05:16:29

问题


Say I've got that form holding some inputs:

<form action="demo_post_enctype.asp" method="post" >
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <input type="submit" value="Submit">
</form>

If I submit this form: which enctype does the browser use?

Is there a well-defined default type?
Or does every browser pick it's own enctype (out of the three allowed ones, of course)?


回答1:


The invalid value default for these attributes is the application/x-www-form-urlencoded state. The missing value default for the enctype attribute is also the application/x-www-form-urlencoded state. (There is no missing value default for the formenctype attribute.)

— HTML 5

This attribute specifies the content type used to submit the form to the server (when the value of method is "post"). 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".

— HTML 4

This determines the mechanism used to encode the form's contents. It defaults to application/x-www-form-urlencoded.

— HTML 3.2




回答2:


Default is:"application/x-www-form-urlencoded", assuming my source is correct.

Source



来源:https://stackoverflow.com/questions/40017138/what-is-the-default-enctype-for-an-html-form

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!