From 23a208aa88cc830624bdfe60c29ebe1bc2c32ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Dvo=C5=99=C3=A1k?= <150935816+Dvorinka@users.noreply.github.com> Date: Tue, 27 May 2025 07:58:51 +0200 Subject: [PATCH] Add files via upload --- admin-dashboard.html | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/admin-dashboard.html b/admin-dashboard.html index ea7fd41..4cc6118 100644 --- a/admin-dashboard.html +++ b/admin-dashboard.html @@ -741,26 +741,29 @@ formData.append('style.isVisible', document.getElementById('bannerVisible').checked); // Log form data for debugging - console.log('Odesílám data:'); + console.log('Odesílám data:'); for (let [key, value] of formData.entries()) { console.log(key, value); } // Create a new headers object - const headers = new Headers(); - // Don't set Content-Type header manually when using FormData - // The browser will set it automatically with the correct boundary + const headers = {}; // Add Authorization header if token exists const token = localStorage.getItem('token'); if (token) { - headers.append('Authorization', `Bearer ${token}`); + headers['Authorization'] = `Bearer ${token}`; } + // Note: Don't set Content-Type header when using FormData with files + // The browser will set it automatically with the correct boundary + const response = await fetch('/api/banner/update', { method: 'POST', headers: headers, - body: formData + body: formData, + // Don't set Content-Type header manually when using FormData with files + // The browser will set it automatically with the correct boundary }); if (!response.ok) {