put($newFilePath, $tempFile)) { @unlink($tempFile); echo json_encode(['success' => true, 'filePath' => $newFilePath]); } else { @unlink($tempFile); http_response_code(500); echo json_encode(['success' => false, 'message' => 'Failed to create file.']); } exit; } http_response_code(400); echo "Invalid request"; exit;