File.webkitRelativePath
No estándar
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
La propiedad File.webkitRelativePath
de solo lectura contiene un USVString
(en-US) el cual especifica la ruta relativa del archivo al directorio seleccionado por el usuario en un elemento <input>
con su webkitdirectory
atributo definido.
Sintaxis
var rulaRelativa = File.webkitRelativePath
Valor
Un USVString
(en-US) conteniendo la ruta del archivo relativa al directorio padre seleccionado por el usuario.
Ejemplo
En este ejemplo,un seleccionador de directorios es mostrado al usuario para permitirle seleccionar uno o mas directorios. Cuando el evento change (en-US)
ocurre, una lista de todos los archivos contenidos dentro de la gerarquia de directorio seleccionado es generado y mostrado.
HTML
<input type="file" id="filepicker" name="fileList" webkitdirectory multiple />
<ul id="listing"></ul>
JavaScript
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);
Resultado
Especificaciones
Especificacion | Estado | Comentario |
---|---|---|
File and Directory Entries API La definición de 'webkitRelativePath' en esta especificación. |
Draft | Especificacion inicial. |
Esta API no tiene especificacion W3C o WHATWG.
Compatibilidad con navegadores
Caracteristica | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Soporte basico | 13 webkit (en-US) | 49 (49) | Sin soporte | Sin soporte | Sin soporte |
Caracteristica | Android | Chrome para Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Soporte basico | Sin soporte | 0.16 webkit (en-US) | 49.0 (49) | Sin soporte | Sin soporte | Sin soporte |