prepare("SELECT credits FROM users WHERE id = ?"); $stmt->execute([$_SESSION['user_id']]); $user = $stmt->fetch(); $user_credits = $user ? $user['credits'] : 0; $upload_dir = 'uploads/'; $uploaded_file_path = null; $error_message = null; if ($user_credits > 0 && $_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['vehicleImage'])) { if ($_FILES['vehicleImage']['error'] === UPLOAD_ERR_OK) { $tmp_name = $_FILES['vehicleImage']['tmp_name']; $name = basename($_FILES['vehicleImage']['name']); $file_ext = strtolower(pathinfo($name, PATHINFO_EXTENSION)); $allowed_ext = ['jpg', 'jpeg', 'png', 'gif']; if (in_array($file_ext, $allowed_ext)) { // Create a unique filename to avoid conflicts $new_filename = uniqid('', true) . '.' . $file_ext; $destination = $upload_dir . $new_filename; if (move_uploaded_file($tmp_name, $destination)) { $uploaded_file_path = $destination; try { $stmt = db()->prepare("INSERT INTO uploads (user_id, file_path) VALUES (?, ?)"); $stmt->execute([$_SESSION['user_id'], $uploaded_file_path]); } catch (PDOException $e) { $error_message = "Database error: " . $e->getMessage(); // Optionally, delete the uploaded file if DB insertion fails unlink($destination); } } else { $error_message = 'Failed to move uploaded file.'; } } else { $error_message = 'Invalid file type. Please upload a JPG, PNG, or GIF image.'; } } else { $error_message = 'File upload failed with error code: ' . $_FILES['vehicleImage']['error']; } } ?>

My Dashboard

Credits: Buy More
0): ?>

Upload Vehicle Photo

Get an instant AI-powered damage analysis. Drag and drop an image or click to select a file.

Drag & drop or click to browse

Supports: JPG, PNG, GIF

Analysis Result

Uploaded Vehicle Image
Image Received

Status: Pending Analysis

You're Out of Credits!

You need to buy more credits to upload and analyze images.

Buy Credits

My Uploads

prepare("SELECT * FROM uploads WHERE user_id = ? ORDER BY created_at DESC"); $stmt->execute([$_SESSION['user_id']]); $uploads = $stmt->fetchAll(); if (count($uploads) > 0): foreach ($uploads as $upload): $status = htmlspecialchars($upload['status']); $status_badge_class = 'bg-secondary'; if ($status === 'pending') { $status_badge_class = 'bg-warning text-dark'; } elseif ($status === 'analyzing') { $status_badge_class = 'bg-info text-dark'; } elseif ($status === 'completed') { $status_badge_class = 'bg-success'; } elseif ($status === 'failed') { $status_badge_class = 'bg-danger'; } ?>
Uploaded Image

Uploaded:

Status:

Analysis Result:
Damage Detected:
Confidence: %
Analysis Failed:
0): ?>
View Report Analyze

You haven't uploaded any images yet.