File() 构造函数创建新 File 对象实例。

句法

new File(bits, name[, options]);
					

参数

bits
数组 of ArrayBuffer , ArrayBufferView , Blob , USVString objects, or a mix of any of such objects, that will be put inside the File . USVString objects are encoded as UTF-8.
名称
USVString representing the file name or the path to the file.
选项 可选
An options object containing optional attributes for the file. Available options are as follows:
  • type : A DOMString representing the MIME type of the content that will be put into the file. Defaults to a value of "".
  • lastModified : A number representing the number of milliseconds between the Unix time epoch and when the file was last modified. Defaults to a value of Date.now() .

范例

var file = new File(["foo"], "foo.txt", {
  type: "text/plain",
});
					

规范

规范 状态 注释
文件 API 工作草案 初始定义

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
File() 构造函数 Chrome 13 Edge 79 Firefox 7 IE No Opera 11.5 Safari 10.1 WebView Android ≤37 Chrome Android 18 Firefox Android 7 Opera Android 11.5 Safari iOS 6 Samsung Internet Android 1.0

图例

完整支持

完整支持

不支持

不支持

另请参阅

元数据

  • 最后修改: