Skip to content

Commit

Permalink
test blyat nahyi pizdec mozhe bytu zalypa 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Aweiro committed Nov 4, 2024
1 parent 5a208f8 commit 29fba08
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions js/photoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,30 +183,30 @@ function deletePhoto(photoName) {
}

// Обробка форми завантаження фотографії
document.getElementById('uploadForm').addEventListener('submit', function (e) {
e.preventDefault();
const formData = new FormData(this);

fetch(`${baseUrl}/upload`, {
method: 'POST',
body: formData,
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
alert(data.message); // Повідомлення про успішне завантаження
loadPhotos();
this.reset();
})
.catch(error => {
document.getElementById('uploadMessage').innerText = 'Помилка завантаження.';
console.error('Error:', error);
});
});
// document.getElementById('uploadForm').addEventListener('submit', function (e) {
// e.preventDefault();
// const formData = new FormData(this);

// fetch(`${baseUrl}/upload`, {
// method: 'POST',
// body: formData,
// })
// .then(response => {
// if (!response.ok) {
// throw new Error('Network response was not ok');
// }
// return response.json();
// })
// .then(data => {
// alert(data.message); // Повідомлення про успішне завантаження
// loadPhotos();
// this.reset();
// })
// .catch(error => {
// document.getElementById('uploadMessage').innerText = 'Помилка завантаження.';
// console.error('Error:', error);
// });
// });

// Завантажуємо фото при завантаженні сторінки
document.addEventListener('DOMContentLoaded', loadPhotos);

0 comments on commit 29fba08

Please sign in to comment.