1 回答
TA贡献1725条经验 获得超7个赞
<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; i++) {
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)
}
}
添加回答
举报