Add debug logging for image upload and QR generation

This commit is contained in:
2025-11-11 18:07:20 +01:00
parent ec8beab484
commit 413c7daee5
2 changed files with 18 additions and 1 deletions

View File

@@ -124,9 +124,11 @@ class ItemController
$idCode = self::generateUniqueIdCode($db);
// Handle image upload
$imagePath = null;
if (isset($_FILES['image']) && $_FILES['image']['error'] === UPLOAD_ERR_OK) {
$imagePath = self::handleImageUpload($_FILES['image']);
error_log("Image uploaded: " . $imagePath);
} else {
error_log("No image uploaded or error: " . ($_FILES['image']['error'] ?? 'no file'));
}
$item = new Item($db, null, $name, $description, $categoryId, null, $idCode, $imagePath, $location);
@@ -159,9 +161,12 @@ class ItemController
}
$fileName = uniqid() . '_' . basename($file['name']);
$targetPath = $uploadDir . $fileName;
error_log("Attempting to move from " . $file['tmp_name'] . " to " . $targetPath);
if (move_uploaded_file($file['tmp_name'], $targetPath)) {
error_log("Image uploaded successfully: " . $targetPath);
return 'uploads/' . $fileName;
}
error_log("Failed to upload image");
return null;
}
@@ -215,6 +220,9 @@ class ItemController
// Handle image upload if new file
if (isset($_FILES['image']) && $_FILES['image']['error'] === UPLOAD_ERR_OK) {
$imagePath = self::handleImageUpload($_FILES['image']);
error_log("Image updated: " . $imagePath);
} else {
error_log("No image update or error: " . ($_FILES['image']['error'] ?? 'no file'));
}
if (empty($name)) {