How to make the picture selected by input (type= "file") be displayed in the specified box

Mar.19,2021

< input type= "file" id= "fileElem" multiple= "accept=" image/* "onchange=" handleFiles (this.files) ">
< div id=" filegroup "> < / div >

function handleFiles(files){  
 var image-group= document.getElementById("filegroup");
      for (var i = 0; i < files.length; iPP) { 
            var img_box = document.createElement("div");
            img_box.setAttribute("class","file-content");
            var img = document.createElement("img");
            img.src = window.URL.createObjectURL(files[i]);
            img.height = 100;
            img.onload = function() {
                window.URL.revokeObjectURL(this.src);
            }
            img_box.appendChild(img);
            image-group.appendChild(img_box)
        }
}


call this handleFiles (this.files) function, how to pass parameters to this

Menu