How to show the image uploaded through the form?

People do not even know anyone with this question) I Think Javascript? In short add the image via input type file is added, but only see the name, how to look at it before adding? I found this script,
//Display uploaded image
// function showFile(e) {
// var files = e.target.files;
// for (var i = 0, f; f = files[i]; i++) {
// if (!f.type.match('image.*')) continue;
// var fr = new FileReader();
// fr.onload = (function(theFile) {
// return function(e) {
// jQuery('#img_up>img').attr("src",e.target.result);
// j('#img_up').css('opacity','1');
// };
// })(f);
//
// fr.readAsDataURL(f);
// }
// }
//
// document.getElementById('files').addEventListener('change', showFile, false);


and how to do it for the gallery for example? Anyway, there are easier options or this will do?
June 14th 19 at 18:19
1 answer
June 14th 19 at 18:21
Solution
Examples of simpler, more complicated

The meaning of one and the same
1. get a list of files (FileList)
2. read them with FileReader
3. show preview
Thanks bro, what you need)! - Gretchen_Daniel commented on June 14th 19 at 18:24
agree) - Vernon.Schu commented on June 14th 19 at 18:27

Find more questions by tags JavaScriptPHPYii