-
-
Save parzibyte/9deb569f7e4a4b71fd72479c4de28adb 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
const archivos = $inputArchivo.files; | |
if (archivos.length <= 0) { | |
return alert("No hay archivos seleccionados"); | |
} | |
const primerArchivo = archivos[0]; | |
const formdata = new FormData(); | |
formdata.append("archivo", primerArchivo); | |
const nombre = "Parzibyte";// Dato de tipo cadena para ejemplificar | |
formdata.append("nombre", nombre); | |
const URL_SERVIDOR = "http://localhost:8080/foto"; // Servidor de Go | |
try { | |
const response = await fetch(URL_SERVIDOR, { | |
method: "POST", | |
body: formdata, | |
}); | |
const respuesta = await response.text(); | |
alert("El servidor dijo: " + respuesta) | |
} catch (e) { | |
alert("Error en el servidor: " + e.message); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment