FileSystemHandle:name 属性

Baseline 2023
Newly available

Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

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

备注: 此特性在 Web Worker 中可用。

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

一个字符串。

示例

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

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

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

  const fileName = fileHandle.name;
}

规范

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

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
name

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

参见