I've created an image using canvas. I want to append the exact image file in the form data and not the url. This is my code.
<video></video>
<button type="button" onclick="turnOn()">turn on cam</button>
<button type="button" onclick="takeSnapshot()">capture image</button>
<script>
function turnOn() {
document.getElementsByTagName('video')[0].play();
var video = document.querySelector('video')
, canvas;
if (navigator.mediaDevices) {
navigator.mediaDevices.getUserMedia({video: true})
.then(function(stream) {
video.src = window.URL.createObjectURL(stream);
})
.catch(function(error) {
document.body.textContent = 'Could not access the camera. Error: ' + error.name + " " + error.message;
});
}
}
function …Run Code Online (Sandbox Code Playgroud)