Latest web development tutorials

HTML form enctype attribute

Tag Reference HTML form HTML <form> tag

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>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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 将空格转换为 "+" 符号,但不编码特殊字符。


Tag Reference HTML form HTML <form> tag