fix: ignore php warnings and improve js error handling for uploads

This commit is contained in:
2026-07-05 10:45:03 +02:00
parent 0ef16ac06d
commit 7ff01ea431
2 changed files with 16 additions and 1 deletions
+15 -1
View File
@@ -357,7 +357,20 @@
body: formData
});
const result = await response.json();
const responseText = await response.text();
let result;
try {
result = JSON.parse(responseText);
} catch (e) {
console.error('Server antwortete nicht mit gültigem JSON:', responseText);
alert('Ein Server-Fehler ist aufgetreten (siehe Konsole). Das Bild wurde eventuell trotzdem hochgeladen.');
form.reset();
previewBox.style.display = 'none';
submitBtn.style.display = 'none';
customerInfo.style.display = 'none';
validationBox.style.display = 'none';
return;
}
if (response.ok) {
alert('Erfolgreich hochgeladen!');
@@ -370,6 +383,7 @@
alert('Fehler: ' + (result.error || 'Unbekannter Fehler'));
}
} catch (error) {
console.error('Upload Error:', error);
alert('Upload fehlgeschlagen. Bitte prüfe deine Verbindung.');
} finally {
submitBtn.innerHTML = originalBtnText;
+1
View File
@@ -1,4 +1,5 @@
<?php
error_reporting(0);
header('Content-Type: application/json');
// Check if request is POST