<?php
header ('Content-Type: application/json');
header('Acess-Control-Allow-Origin: *');
header('Acess-Control-Allow-Methods: Post');


include 'confing.php';

$data=json_decode(file_get_contents("php://input"),true);
$randomNumber = str_pad(mt_rand(0, 9999999), 7, '0', STR_PAD_LEFT);
$profile_image=$data['profile_image'];
$type=$data['type'];
$unique_id=$data['unique_id'];

	 $imagePath = "upload/image/Img_".rand(1,99999).".png";
		   file_put_contents($imagePath,base64_decode($profile_image));


if($type=='user'){
    $sql="UPDATE user SET 
profile_image ='{$imagePath}'
WHERE 	unique_id ={$unique_id}";
}
else{
    $sql="UPDATE vender SET 
profile_image ='{$imagePath}'
WHERE 	unique_id ={$unique_id}";
}
    





// echo ($sql);



$result=mysqli_query($conn,$sql) or die("error while");



if($result){

    echo json_encode(array('message'=>'done','status'=>'1'));


}else{

    echo json_encode(array('id'=>'is not done','status'=>'0'));

}


?>