diff --git a/assets/images/uploads/thumbnail_694350f6c1cc1.jpg b/assets/images/uploads/thumbnail_694350f6c1cc1.jpg new file mode 100644 index 0000000..88be0ec Binary files /dev/null and b/assets/images/uploads/thumbnail_694350f6c1cc1.jpg differ diff --git a/includes/ImageProcessor.php b/includes/ImageProcessor.php index 00cffea..4048336 100644 --- a/includes/ImageProcessor.php +++ b/includes/ImageProcessor.php @@ -12,12 +12,14 @@ class ImageProcessor { */ public static function processAndSaveImage(array $file) { if (!isset($file['tmp_name']) || $file['error'] !== UPLOAD_ERR_OK) { + error_log("ImageProcessor: No file uploaded or an error occurred. File error code: " . ($file['error'] ?? 'unknown')); return false; // No file uploaded or an error occurred } // Validate file type $allowedTypes = ['image/jpeg', 'image/png', 'image/gif']; if (!in_array($file['type'], $allowedTypes)) { + error_log("ImageProcessor: Invalid file type uploaded: " . $file['type']); return false; // Invalid file type } @@ -33,11 +35,13 @@ class ImageProcessor { // Move the uploaded file if (!move_uploaded_file($file['tmp_name'], $targetPath)) { + error_log("ImageProcessor: Failed to move uploaded file from " . $file['tmp_name'] . " to " . $targetPath); return false; // Failed to move uploaded file } // Resize image if (!self::resizeImage($targetPath, $file['type'])) { + error_log("ImageProcessor: Failed to resize image: " . $targetPath); // If resizing fails, you might want to delete the original uploaded file unlink($targetPath); return false; @@ -75,6 +79,7 @@ class ImageProcessor { $image = imagecreatefromgif($imagePath); break; default: + error_log("ImageProcessor: Unsupported image type for resizing: " . $mimeType); return false; // Unsupported image type for resizing } diff --git a/submit.php b/submit.php index 4f91207..978a88e 100644 --- a/submit.php +++ b/submit.php @@ -1,8 +1,14 @@ prepare("INSERT INTO links (user_id, subcategory_id, title, url, description, thumbnail_url, status) VALUES (?, ?, ?, ?, ?, ?, ?)"); $stmt->execute([$_SESSION['user_id'], $subcategory_id, $title, $url, $description, $thumbnail_url, $status]); $success = true; + error_log("submit.php: Database insertion successful."); } catch (PDOException $e) { $errors[] = "Database error: " . $e->getMessage(); + error_log("submit.php: Database error: " . $e->getMessage()); } } }