function upImg(obj){ var imgFile = obj.files[0]; console.log(imgFile); var img = new Image(); var fr = new FileReader(); fr.onload = function(){ var htmlStr = '<div class="upWrap">'; htmlStr += '<div class="fileWrap">'; htmlStr += '<input type="file" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" onchange="upImg(this)"/>'; htmlStr += '</div>'; htmlStr += '<div class="imgWrap upedImg"><span class="deleteImg">X</span>'; htmlStr += '<img src="'+fr.result+'" alt="" />'; htmlStr += '</div>'; htmlStr += '</div>'; $('.imgOnloadWrap').append(htmlStr); obj.value = ''; } fr.readAsDataURL(imgFile); }