<?php include 'connection.php';

// Check if the image data is received
if(isset($_POST['imageData'])){

$imgname = $_REQUEST['name'];
    // Remove the "data:image/png;base64," prefix from the received data
    $imageData = str_replace('data:image/png;base64,', '', $_POST['imageData']);
    
    // Decode the base64-encoded image data
    $decodedImage = base64_decode($imageData);
    
	   // $signature = uniqid() . '.png';
    // Set the path where you want to save the image
    $filePath = 'signatures/' . uniqid() . '.png';
    
    // Save the image to the specified path
    if(file_put_contents($filePath, $decodedImage)){
        echo 'success';
	
    } else {
        echo 'error';
    }
} else {
    echo 'No image data received.';
}

	
		echo $qryauto="insert into signatures_data(signatures) values ('$filePath')";
$rauto=mysqli_query($conn,$qryauto);
?>
