Thuộc tính HTML <input> formenctype

❮ Thẻ HTML <input>

Thí dụ

Gửi dữ liệu biểu mẫu được mã hóa mặc định (nút gửi đầu tiên) và được mã hóa thành "nhiều phần / biểu mẫu-dữ liệu" (nút gửi thứ hai):

<form action="/action_page_binary.asp" method="post">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <input type="submit" value="Submit">
  <input type="submit" formenctype="multipart/form-data" value="Submit as Multipart/form-data">
</form>

Định nghĩa và Cách sử dụng

Thuộc formenctypetính chỉ định cách dữ liệu biểu mẫu được mã hóa khi gửi đến máy chủ (chỉ dành cho biểu mẫu có method="post")

Thuộc formenctypetính ghi đè enctypethuộc tính của <form>phần tử.

Lưu ý: Thuộc formenctypetính được sử dụng với type="submit" type="image".


Hỗ trợ trình duyệt

Các số trong bảng chỉ định phiên bản trình duyệt đầu tiên hỗ trợ đầy đủ thuộc tính.

Attribute
formenctype Yes 10.0 Yes 5.1 10.6

Cú pháp

<input formenctype="value">

Giá trị thuộc tính

Value Description
application/x-www-form-urlencoded Default. All characters are encoded before sent (spaces are converted to "+" symbols, and special characters are converted to ASCII HEX values)
multipart/form-data  This value is necessary if the user will upload a file through the form
text/plain Sends data without any encoding at all. Not recommended

❮ Thẻ HTML <input>