<?php

// update_image.php

include '../config/conexion.php';



if ($_SERVER['REQUEST_METHOD'] === 'POST') {





    $id = isset($_POST['id']) ? intval($_POST['id']) : 0;

    $description = isset($_POST['description']) ? trim($_POST['description']) : '';

    

    if ($id > 0 && !empty($description)) {

        $sql = "UPDATE accounts SET imagen = ? WHERE id = ?";

        $stmt = $conexion->prepare($sql);

        $stmt->bind_param("si", $description, $id);

        

        if ($stmt->execute()) {

            echo json_encode(["success" => true]);

        } else {

            echo json_encode(["success" => false, "message" => "Error al actualizar la imagen."]);

        }

        $stmt->close();

    } else {

        echo json_encode(["success" => false, "message" => "Datos inválidos."]);

    }

} else {

    echo json_encode(["success" => false, "message" => "Método no permitido."]);

}



$conexion->close();

?>