HTMLFormElement.enctype

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

HTMLFormElement.enctype 属性常用来指明提交表单的内容类型,可选的值如下:

  • application/x-www-form-urlencoded: 初始的默认值
  • multipart/form-data: 适用于使用<input> 标签上传文件
  • text/plain: HTML5 引入的类型

这些值可以通过元素 <button> or <input> 的属性 form.enctype 来改写

语法

string = form.enctype
form.enctype = string

例子

form.enctype = "application/x-www-form-urlencoded";

参考