Changes api call to import file

pull/6/head
Luis Gerardo Romero Garcia 2023-11-07 10:13:54 +01:00
parent 54d741eb5a
commit d813749032
1 changed files with 16 additions and 1 deletions

View File

@ -334,7 +334,22 @@
// Aquí puedes realizar la llamada al API para subir el archivo utilizando fetch o la biblioteca que prefieras.
const archivo = fileInput.files[0];
const formData = new FormData();
formData.append('archivo', archivo);
formData.append('file_input_name', archivo);
fetch('https://localhost/opengnsys/rest/dhcp/upload', {
method: 'POST',
body: formData
})
.then(response => {
if (response.ok) {
console.log('Archivo subido con éxito');
location.reload();
} else {
console.error('Error al subir el registro');
}
})
.catch(error => {
console.error('Error al realizar la solicitud:', error);
});
}
}