<?php
header("Content-Type: text/plain");

// Read the raw binary data sent by the Luckfox board
$data = file_get_contents('php://input');

if ($data) {
    // Save the data to a file named snapshot.jpg in the same folder
    $result = file_put_contents('snapshot.jpg', $data);
    
    if ($result !== false) {
        echo "Success! Saved " . strlen($data) . " bytes.";
    } else {
        echo "Error: Failed to write file. Check folder permissions.";
    }
} else {
    echo "Error: No data received.";
}
?>