0

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">?

deceze
  • 510,633
  • 85
  • 743
  • 889
  • look at this full example https://makitweb.com/how-to-capture-picture-from-webcam-with-webcam-js/ – G-Man Jan 20 '20 at 14:35
  • @G-Man I have already checked out the library but the problem isn't solved just with it. I found a workaround for what I had to do. –  Jan 20 '20 at 15:09

0 Answers0