HTML <form> enctype 属性
实例
发送以 "multipart/form-data" 编码的表单数据:
<form action="/action_page_binary.asp"
method="post" enctype="multipart/form-data">
<label for="fname">First name:</label>
<input type="text" id="fname"
name="fname"><br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname"><br><br>
<input
type="submit" value="提交">
</form>
亲自试一试 »
定义和用法
enctype 属性规定在将表单数据发送到服务器之前如何对其进行编码。
注释: 只有 method="post" 时才使用 enctype 属性。
浏览器支持
属性 | |||||
---|---|---|---|---|---|
enctype | Yes | Yes | Yes | Yes | Yes |
语法
<form enctype="value">
属性值
值 | 描述 |
---|---|
application/x-www-form-urlencoded | 默认。在发送前对所有字符进行编码(将空格转换为 "+" 符号,特殊字符转换为 ASCII HEX 值)。 |
multipart/form-data | 不对字符编码。当使用有文件上传控件的表单时,该值是必需的。 |
text/plain | 将空格转换为 "+" 符号,但不编码特殊字符。 |
❮ HTML <form> 标签