save and display image captured from input type=file

rawatdeepesh picture rawatdeepesh · Apr 7, 2017 · Viewed 8.3k times · Source

I have a webpage with capture image from the Available camera feature. For the web version it simply places the video capture onto a canvas. However for a phone, I am using <input class="btn btn-info" type="file" accept="image/*" id="cameraCapture" capture="camera"> to capture a picture. It asks the user to either capture the image using the phone's camera or upload from its filesystem/gallery etc. Once the image is clicked it simply places the image's name next to the button. Is there a way to access this image and display it in the same page.

Thanks in advance

Answer

Nadia Ghebreial picture Nadia Ghebreial · Apr 7, 2017

You can do that with JS using FileReader object.

Take a look at this answer: preview-an-image-before-it-is-uploaded

I hope it helps