<?php
include 'connect.php';
$slider_id = $_POST['slider_id'];
if (isset($_FILES['sliderImage'])) {
    $imageName = $_FILES['sliderImage']['name'];
    $imageTmp = $_FILES['sliderImage']['tmp_name'];
    $imageExtension = pathinfo($imageName, PATHINFO_EXTENSION); // Get the file extension

    $folderName = "../images/Slider/";
    $newImageName = uniqid() . '.' . $imageExtension;
    $destination = $folderName . $newImageName;
    $image = "images/Slider/" . $newImageName;

    if (move_uploaded_file($imageTmp, $destination)) {
        // Update all fields
        $sql = "UPDATE a_slider SET SliderImage ='$image' WHERE SliderID=$slider_id";
        $result = mysqli_query($con, $sql);

        if ($result) {
            echo "Image updated successfully.";
        } 
        else{
            echo mysqli_error($con);
        }
    }
  
}
?>