I need to take a snapshot with my webcam and use the taken picture as a file into an <input type="file">
I managed to take the snapshot using webcam.js
.
Now I need to set the file of my input as the snapshot I just took.
How I take the snapshot:
HTML:
<input type=button value="Take Snapshot" onClick="take_snapshot()">
JS:
function take_snapshot() {
// take snapshot and get image data
Webcam.snap( function(data_uri) {
// display results in page
document.getElementById('results').innerHTML =
'<h2>Here is your image:</h2>' +
'<img src="'+data_uri+'"/>';
} );
}
In the JS the data_uri
is the base64 of the snapshot I just took.
Is there a way to use the base64 string as the input file in my <input type="file">
?