发送编码为 multipart/form-data 的表单数据:
<form action="/action_page_binary.asp" method="post" enctype="multipart/form-data"> <label for="fname">名:</label> <input type="text" id="fname" name="fname"><br> <label for="lname">姓:</label> <input type="text" id="lname" name="lname"><br> <input type="submit" value="提交"> </form>
enctype 属性指定表单数据在提交到服务器时应如何编码。
注意: 只有在 method="post" 时才能使用 enctype 属性。
| 属性 Attribute |
|
|
|
|
|
|---|---|---|---|---|---|
| enctype | Yes | Yes | Yes | Yes | Yes |
<form enctype="value">
| 值 Value | 描述 Description |
|---|---|
| application/x-www-form-urlencoded | 默认。 所有字符在发送前都经过编码(空格转换为 + 符号,特殊字符转换为 ASCII HEX 值) |
| multipart/form-data | 如果用户将通过表单上传文件,则此值是必需的 |
| text/plain | 发送完全没有任何编码的数据。 不建议 |