'Method not allowed']); } if (!isset($_FILES['file'])) { http_response_code(400); return json_encode(['error' => 'No file uploaded']); } $uploadedImage = uploadImage($_FILES['file']); if ($uploadedImage) { return json_encode(['location' => "/$uploadedImage"]); } else { http_response_code(400); return json_encode(['error' => 'Failed to upload image. Please check file format and size.']); }