Screen Capture Example Capture Screenshot
<?php
header('Content-Type: application/json');
// Get the raw POST data
$data = json_decode(file_get_contents("php://input"));
// Extract image data and file name
$imageData = $data->imageData;
$fileName = $data->fileName;
// Remove the "data:image/png;base64," prefix from the base64 data
$imageData = str_replace('data:image/png;base64,', '', $imageData);
// Decode the base64 data to binary
$imageData = base64_decode($imageData);
// Specify the path to the "images" folder
$filePath = 'images/' . $fileName;
// Save the image to the "images" folder
file_put_contents($filePath, $imageData);
// Send a response back to the client
echo json_encode(['message' => 'Screenshot saved successfully.']);
?>