这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。

只读 webkitEntries 特性为 HTMLInputElement interface contains an array of file system entries (as objects based on FileSystemEntry ) representing files and/or directories selected by the user using an <input> element of type file , but only if that selection was made using drag-and-drop: selecting a file in the dialog will leave the property empty (bug 1326031).

The array can only contain directories if the webkitdirectory 特性为 true . This means the <input> element was configured to let the user choose directories.

This property is called webkitEntries in the specification due to its origins as a Google Chrome-specific API. It's likely to be renamed someday.

句法

var entries = HTMLInputElement.webkitEntries;
					

An array of objects based on FileSystemEntry , each representing one file which is selected in the <input> element. More specifically, files are represented by FileSystemFileEntry objects, and, if they're allowed, directories are represented by FileSystemDirectoryEntry 对象。

范例

This example shows how to create a file selection <input> element and process the selected files.

HTML

<input id="files" type="file" multiple>
					

JavaScript

document.getElementById("files").addEventListener("change", function(event) {
  event.target.webkitEntries.forEach(function(entry) {
    /* do stuff with the entry */
  });
});
					

Each time a change event occurs, this code iterates over the selected files, obtaining their FileSystemEntry -based objects and acting on them.

规范

规范 状态 注释
文件和目录条目 API
The definition of 'webkitEntries' in that specification.
草案 最初的规范。

此 API 没有正式的 W3C 或 WHATWG (Web 超文本应用程序技术工作组) 规范。

浏览器兼容性

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
webkitEntries 非标 Chrome 13 Edge ≤18 Firefox 50 IE No Opera No Safari 11.1 WebView Android ≤37 Chrome Android 18 Firefox Android 50 Opera Android No Safari iOS 11.3 Samsung Internet Android Yes

图例

完整支持

完整支持

不支持

不支持

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

另请参阅

元数据

  • 最后修改: