D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
vitalityhealth
/
public_html
/
aa
/
invite
/
Filename :
save_screenshot.php
back
Copy
<?php include 'cn.php'; ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); if (isset($_POST['screenshot'])) { $imageData = $_POST['screenshot']; $rand = $_POST['rand']; // Generate a unique filename $uniqueFileName = time() . '_' . mt_rand() . '.png'; // Define the path where you want to save the screenshot $filePath = 'screenshot/' . $uniqueFileName; // Decode and save the image data to the server $decodedImage = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $imageData)); // file_put_contents($filePath, $decodedImage); $imageResource = imagecreatefromstring($decodedImage); // Save the image to the server imagepng($imageResource, $filePath); // Free up memory by destroying the image resource imagedestroy($imageResource); // Insert the file path and unique name into the database $sql = "UPDATE weddinginv1 SET image_path = '$filePath' WHERE id = $rand"; // echo $sql;exit; $result = $con->query($sql); // print_r($result);exit; if ($result==1) { echo 'Screenshot saved successfully.'; } else { echo 'Error saving screenshot.'; } } else { echo 'No screenshot data received.'; } ?>