I am currently trying to take a photo through a laptops webcam and save it to the Oracle Apex Database.
For capturing a users photo I use simple JS code (see below). How can I save my image to the DB? I figured converting the image to a blob would be the simplest idea, but I am stuck after converting... Can I set a "Display Only" or "Upload File" Item with my Blob?
Thanks a lot for the help!
<html>
Videoplayer will follow here
<video id="player" autoplay></video>
<button type="button" id="capture">Capture</button>
<canvas id="canvas" class="canvasclass"></canvas>
<button type="button" id="save">Save Photo</button>
<div id="urldiv">URL here</div>
<script>
const player = document.getElementById('player');
const canvas = document.getElementById('canvas');
const context = canvas.getContext('2d');
const captureButton = document.getElementById('capture');
const savebutton = document.getElementById('save');
const urlplace = document.getElementById('urldiv');
const constraints = {
audio:false,video:true
};
captureButton.addEventListener('click', () => {
context.drawImage(player, 0, 0, canvas.width, canvas.height);
// Stop all video streams.
player.srcObject.getVideoTracks().forEach(track => track.stop());
});
navigator.mediaDevices.getUserMedia(constraints)
.then((stream) => {
// Attach the video stream to the video element and autoplay.
player.srcObject = stream;
});
savebutton.addEventListener('click', () => {
const dataurl = canvas.toDataURL();
urlplace.innerHTML = dataurl;
window.prompt("Copy to clipboard: Ctrl+C, Enter", dataurl);
// $s("ITEM_NAME", dataurl);
})
</script>
<html>