HTML 内容如下:
<input type="file" id="files">
JavaScript 内容如下:
var reader = new FileReader();
$("#files").on('change',function(e){
var input = document.getElementById("files");
var files = this.files;
reader.readAsDataURL(files[0]);
reader.onload = function(e){
console.log(e);
if(dataArr.length<=4){
$(".uploadImg .img").remove();
dataArr.push(e.target.result);
imgArr.push(files);
$(".uploadName .length").text(dataArr.length+'/5');
var html = template('imgUploads',{dataArr:dataArr});
$(".before").before(html);
}
}
console.log(imgArr);
})