<?php

// Created by Ibrohimjon Ahmadjonov Ilhomjon o'g'li on 05.07.2020
  
$id = $_POST['id'];
$eski = $_POST['eski'];
$rasmi = $_POST['rasm'];
 $path = "";
if(empty($rasmi)){
	$path ="";
}else{
    $path = "img/$id.png"; 
}
$eski_path = "";
if(empty($eski)){
	$eski_path ="";
}else{
    $eski_path = "img/$eski.png"; 
}

if(file_exists($eski_path)) {
    unlink($eski_path); 
} 
if(file_exists($path)) {
    unlink($path); 
} 
  
if(!empty($rasmi)){
    file_put_contents($path,base64_decode($rasmi));
    echo 'ok';
} else{
    echo 'no_c';
}
 
?>