aws_faktury/scripts.js
dzikafoczka 4250458b60 faktury
2024-12-21 22:11:47 +01:00

31 lines
1.2 KiB
JavaScript

document.getElementById('uploadForm').addEventListener('submit', function (event) {
event.preventDefault();
const fileInput = document.getElementById('file');
const file = fileInput.files[0];
if (file) {
const formData = new FormData();
formData.append('file', file);
fetch('http://127.0.0.1/invoice', {
method: 'POST',
body: formData,
})
.then(response => response.json())
.then(data => {
document.getElementById('responseMessage').innerHTML = `
<p>Plik zosta³ pomyœlnie przes³any!</p>
<pre>${{JSON.stringify(data, null, 2)}}</pre>
`;
})
.catch(error => {
document.getElementById('responseMessage').innerHTML = `
<p>B³¹d podczas przesy³ania pliku: ${error.message}</p>
`;
});
} else {
alert('Proszê wybraæ plik!');
}
});