File: webkitRelativePath プロパティ
メモ: この機能はウェブワーカー内で利用可能です。
webkitRelativePath
は File
インターフェイスの読み取り専用プロパティで、webkitdirectory
属性が設定された <input>
要素において、ユーザーが選択したディレクトリーに対するファイルのパスを指定する文字列を保持します。
値
ユーザーが選択した祖先ディレクトリーを基準にしたファイルのパスを含む文字列。
例
この例では、ユーザーが 1 つまたは複数のディレクトリーを選択することができるディレクトリーピッカーが表示されます。 change
イベントが発生すると、選択されたディレクトリー階層に含まれるすべてのファイルのリストが生成され、表示されます。
HTML
html
<input type="file" id="filepicker" name="fileList" webkitdirectory multiple />
<output id="output"></output>
JavaScript
js
const output = document.getElementById("output");
const filepicker = document.getElementById("filepicker");
filepicker.addEventListener("change", (event) => {
const files = event.target.files;
for (const file of files) {
output.textContent += `${file.webkitRelativePath}\n`;
}
});
結果
仕様書
Specification |
---|
File and Directory Entries API # dom-file-webkitrelativepath |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
webkitRelativePath |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
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.