<?php if (!defined('DASHBOARD_ROOT')) { http_response_code(403); exit; } header('Content-Type: application/json'); CSRF::enforce(); RBAC::enforce('modify.listing'); if ($_SERVER['REQUEST_METHOD'] !== 'POST' || !isset($_FILES['image'])) { echo json_encode(['success' => false, 'error' => 'No file uploaded.']); exit; } require_once DASHBOARD_ROOT . '/core/image_process.php'; try { $filename = ImageProcess::process($_FILES['image']); AuditLogger::log('image.uploaded', 'listing', null, ['filename' => $filename]); echo json_encode(['success' => true, 'filename' => $filename]); } catch (\Throwable $e) { echo json_encode(['success' => false, 'error' => $e->getMessage()]); } 