<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $imageData = $_POST['photo'];
    $imageData = str_replace('data:image/jpeg;base64,', '', $imageData);
    $imageData = base64_decode($imageData);

    $filename = 'uploads/' . uniqid() . '.jpg';

    if (file_put_contents($filename, $imageData)) {
        http_response_code(200);
    } else {
        http_response_code(500);
    }
}
?>
 