<?php

    session_start();

    include "../db.php";

    date_default_timezone_set('Asia/Kolkata');

     $currentTime = date('jS  F Y');

    if ( !isset($_SESSION['uid']) && !isset($_SESSION['uref']) && !isset($_SESSION['utype']) )

        header("Location: logout.php");

?>



<?php





if (isset($_POST['image'])) {



    // image upload

    $data = $_POST["image"];

    $image_array_1 = explode(";", $data);

    $image_array_2 = explode(",", $image_array_1[1]);

    $data = base64_decode($image_array_2[1]);

    $imageName = '../upload/corpedImage/'.rand() . '.jpg';

    file_put_contents($imageName, $data);



    // User Input

    $refid = $_POST['refid'];



    $ins_sql = "UPDATE data SET data_img = '$imageName' WHERE data_sl_no = '$refid' ";

    mysqli_query($con, $ins_sql) ;

    if (mysqli_query($con, $ins_sql)) {

        if(!empty($_POST["previousThumbnail"])){

            unlink($_POST["previousThumbnail"]);

        }

        

    }

}





?>