非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。
File.webkitRelativePath
is a read-only property that contains a
USVString
which specifies the file's path relative to the directory selected by the user in an
<input>
element with its
webkitdirectory
attribute set.
relativePath = File.webkitRelativePath
A
USVString
containing the path of the file relative to the ancestor directory the user selected.
In this example, a directory picker is presented which lets the user choose one or more directories. When the
change
event occurs, a list of all files contained within the selected directory hierarchies is generated and displayed.
<input type="file" id="filepicker" name="fileList" webkitdirectory multiple /> <ul id="listing"></ul>
document.getElementById("filepicker").addEventListener("change", function(event) {
let output = document.getElementById("listing");
let files = event.target.files;
for (let i=0; i<files.length; i++) {
let item = document.createElement("li");
item.innerHTML = files[i].webkitRelativePath;
output.appendChild(item);
};
}, false);
| 规范 | 状态 | 注释 |
|---|---|---|
|
文件和目录条目 API
The definition of 'webkitRelativePath' in that specification. |
草案 | 最初的规范。 |
此 API 没有正式的 W3C 或 WHATWG (Web 超文本应用程序技术工作组) 规范。
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
webkitRelativePath
|
Chrome
13
Prefixed
|
Edge 13 | Firefox 49 | IE No | Opera No | Safari 11.1 | WebView Android Yes |
Chrome Android
18
Prefixed
|
Firefox Android 49 | Opera Android No | Safari iOS 11.3 |
Samsung Internet Android
1.0
Prefixed
|
完整支持
不支持
要求使用供应商前缀或不同名称。
File
fileName
fileSize
lastModified
lastModifiedDate
mozFullPath
名称
type
webkitRelativePath