HTML form enctype attribute
Examples
Send to "multipart / form-data" encoded form data:
<form action="demo_post_enctype.html"
method="post" enctype="multipart/form-data">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="提交">
</form>
method="post" enctype="multipart/form-data">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="提交">
</form>
try it"
Browser Support
All major browsers support enctype attribute.
Definition and Usage
enctype attribute specifies the form before sending data to the server how they are encoded.
Note: Only themethod = "post" when using the enctype attribute.
Differences between HTML 4.01 and HTML5
no.
grammar
<form enctype="value">
Property Value
值 | 描述 |
---|---|
application/x-www-form-urlencoded | 默认。在发送前对所有字符进行编码(将空格转换为 "+" 符号,特殊字符转换为 ASCII HEX 值)。 |
multipart/form-data | 不对字符编码。当使用有文件上传控件的表单时,该值是必需的。 |
text/plain | 将空格转换为 "+" 符号,但不编码特殊字符。 |
HTML <form> tag