このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

FileSystemHandle.name

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2023年3月⁩.

安全なコンテキスト用: この機能は一部またはすべての対応しているブラウザーにおいて、安全なコンテキスト (HTTPS) でのみ利用できます。

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①

ブラウザーの互換性

関連情報