Created
August 7, 2019 16:16
-
-
Save parzibyte/cf87b3a083ed2181dbbbfd4e8a01891b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
btnEnviar.addEventListener("click", () => { | |
if (inputFile.files.length > 0) { | |
let formData = new FormData(); | |
formData.append("archivo", inputFile.files[0]); // En la posición 0; es decir, el primer elemento | |
fetch("guardar.php", { | |
method: 'POST', | |
body: formData, | |
}) | |
.then(respuesta => respuesta.text()) | |
.then(decodificado => { | |
console.log(decodificado); | |
}); | |
} else { | |
// El usuario no ha seleccionado archivos | |
alert("Selecciona un archivo"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment