File.name
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Retorna el nombre del archivo representado por el objeto File
. Por razones de seguridad, la ruta de directorios es excluida de esta propiedad.
Sintaxis
js
var nombre = file.name;
Valor
Una cadena, conteniendo el nombre del archivo sin la ruta de directorios, por ejemplo: "Mi resumen.rtf".
Ejemplo
html
<input type="file" multiple onchange="processSelectedFiles(this)" />
js
function processSelectedFiles(fileInput) {
var files = fileInput.files;
for (var i = 0; i < files.length; i++) {
alert("Filename " + files[i].name);
}
}
Prueba el resultado:
Especificaciones
Specification |
---|
File API # dfn-name |
Compatibilidad con navegadores
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Has more compatibility info.
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.