In my HTML form I have input filed with type file for example :
<input type="file" multiple>
Then I'm selecting multiple files by clicking that input button.
Now I want to show preview of selected images before submitting form . How to do that in HTML 5?
Best Answer
Here's a quick example that makes use of the
URL.createObjectURL
to render a thumbnail by setting thesrc
attribute of an image tag to a object URL:The html code:
The JavaScript code:
The code snippet in the HTML example below filters out images from the user's selection and renders selected files into multiple thumbnail previews: