FileSystemHandle:name 属性

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

安全上下文: 此项功能仅在一些支持的浏览器安全上下文(HTTPS)中可用。

FileSystemHandle 接口的 name 只读属性返回句柄所代表的条目的名称。

一个字符串。

示例

下面的函数允许用户在文件选择器选择一个文件并获取句柄的 name 属性。

js
// 存放对文件句柄的引用
let fileHandle;

async function getFile() {
  // 打开文件选择器
  [fileHandle] = await window.showOpenFilePicker();

  const fileName = fileHandle.name;
}

规范

Specification
File System Standard
# ref-for-dom-filesystemhandle-name①

浏览器兼容性

BCD tables only load in the browser

参见