Using form input to access camera and immediately upload photos using web app Using form input to access camera and immediately upload photos using web app javascript javascript

Using form input to access camera and immediately upload photos using web app


It's really easy to do this, simply send the file via an XHR request inside of the file input's onchange handler.

<input id="myFileInput" type="file" accept="image/*;capture=camera">var myInput = document.getElementById('myFileInput');function sendPic() {    var file = myInput.files[0];    // Send file here either by adding it to a `FormData` object     // and sending that via XHR, or by simply passing the file into     // the `send` method of an XHR instance.}myInput.addEventListener('change', sendPic, false);