位置:首页  >    > js上传图片-预览图片

js上传图片-预览图片

http://www.cnblogs.com/fsjohnhuang/p/3925827.html



https://github.com/fsjohnhuang/preview/releases/tag/v1.2.0



    if (isRender(_, _.fileEl.files[0].name, isExpectedMIME)){ if (!img){
         img = new Image();  img.className = imgCls; 
 // img.style.width = previewEl.offsetWidth + 'px'; 
 // img.style.height = previewEl.offsetHeight + 'px';  
// previewEl.appendChild(img);  
}
      img.src = src;  img.style.width = "200px";   
alert("2图片的宽度为"+img.width+",2长度为"+img.height); 
//    img.style.height = img.offsetHeight;  
img.onload = function(){ 
alert("图片的宽度为"+this.width+",长度为"+this.height);  
previewEl.appendChild(img);  
var imgwidth = img.width;  
var imgheight = img.height;  
alert(imgwidth + "," + imgheight);  
};      
}

0
文章属性
精彩评论