目录

HTML DOM input file 对象


输入文件上传对象

输入 FileUpload 对象表示 type="file" 的 HTML <input> 元素。

访问输入文件上传对象

您可以使用 getElementById() 访问 type="file" 的 <input> 元素:

示例

var x = document.getElementById("myFile");
亲自试一试 »

提示:您还可以通过搜索来访问 <input type="file">元素表格的集合。

创建输入文件上传对象

您可以使用 document.createElement() 方法创建 type="file" 的 <input> 元素:

示例

var x = document.createElement("INPUT");
x.setAttribute("type", "file");
亲自试一试 »


输入文件上传对象属性

Property Description
accept Sets or returns the value of the accept attribute of the file upload button
autofocus Sets or returns whether a file upload button should automatically get focus upon page load
defaultValue Sets or returns the default value of the file upload button
disabled Sets or returns whether the file upload button is disabled, or not
files Returns a FileList object that represents the file or files selected with the file upload button
form Returns a reference to the form that contains the file upload button
multiple Sets or returns whether a user is allowed to select more than one file in the file upload field
name Sets or returns the value of the name attribute of the file upload button
required Sets or returns whether a file in the file upload field must be selected before submitting a form
type Returns which type of form element the file upload button is
value Returns the path or the name of the selected file

标准属性和事件

输入文件上传对象还支持标准特性事件


相关页面

HTML 教程:HTML 表单

HTML 参考:HTML <输入> 标签

HTML 参考:HTML <input> 类型属性