<?php
if (isset($_POST['image'])) {
    $base64_image = $_POST['image'];
    $image_parts = explode(";base64,", $base64_image);
    $image_base64 = base64_decode($image_parts[1]);
    
    $fileName = 'tasarim_' . time() . '.png';
    $filePath = $_SERVER['DOCUMENT_ROOT'] . '/uploads/' . $fileName;
    
    file_put_contents($filePath, $image_base64);
    
    echo json_encode([
        "success" => true,
        "file" => $filePath
    ]);
} else {
    echo json_encode([
        "success" => false,
        "message" => "Veri alınamadı."
    ]);
}
?>