Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 7, 2019 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/cf87b3a083ed2181dbbbfd4e8a01891b to your computer and use it in GitHub Desktop.
Save parzibyte/cf87b3a083ed2181dbbbfd4e8a01891b to your computer and use it in GitHub Desktop.
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