标签:图片预览 javascrip 预览 ade style var reader ons ima
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+‘" />‘; htmlStr += ‘</div>‘; htmlStr += ‘</div>‘; $(‘.imgOnloadWrap‘).append(htmlStr); obj.value = ‘‘; } fr.readAsDataURL(imgFile); }
1 function upImg(obj){ 2 var imgFile = obj.files[0]; 3 console.log(imgFile); 4 var img = new Image(); 5 var fr = new FileReader(); 6 fr.onload = function(){ 7 var htmlStr = ‘<div class="upWrap">‘; 8 htmlStr += ‘<div class="fileWrap">‘; 9 htmlStr += ‘<input type="file" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" onchange="upImg(this)"/>‘; 10 htmlStr += ‘</div>‘; 11 htmlStr += ‘<div class="imgWrap upedImg"><span class="deleteImg">X</span>‘; 12 htmlStr += ‘<img src="‘+fr.result+‘" />‘; 13 htmlStr += ‘</div>‘; 14 htmlStr += ‘</div>‘; 15 $(‘.imgOnloadWrap‘).append(htmlStr); 16 obj.value = ‘‘; 17 } 18 fr.readAsDataURL(imgFile); 19 }
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+‘" />‘; htmlStr += ‘</div>‘; htmlStr += ‘</div>‘; $(‘.imgOnloadWrap‘).append(htmlStr); obj.value = ‘‘; } fr.readAsDataURL(imgFile); }
1 function upImg(obj){ 2 var imgFile = obj.files[0]; 3 console.log(imgFile); 4 var img = new Image(); 5 var fr = new FileReader(); 6 fr.onload = function(){ 7 var htmlStr = ‘<div class="upWrap">‘; 8 htmlStr += ‘<div class="fileWrap">‘; 9 htmlStr += ‘<input type="file" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" onchange="upImg(this)"/>‘; 10 htmlStr += ‘</div>‘; 11 htmlStr += ‘<div class="imgWrap upedImg"><span class="deleteImg">X</span>‘; 12 htmlStr += ‘<img src="‘+fr.result+‘" />‘; 13 htmlStr += ‘</div>‘; 14 htmlStr += ‘</div>‘; 15 $(‘.imgOnloadWrap‘).append(htmlStr); 16 obj.value = ‘‘; 17 } 18 fr.readAsDataURL(imgFile); 19 }
标签:图片预览 javascrip 预览 ade style var reader ons ima
原文地址:http://www.cnblogs.com/sylwh/p/7906061.html