js获取input上传图片的尺寸

xiaoxiao2021-02-28  89

<input type="file" id="tp" name="tp"/>      <buttonοnclick="xxx()"></button> function xxx(){ var f = document.getElementByIdx_x_x_x_x("tp").files[0];     var reader = newFileReader();     reader.onload = function(e) {         var data = e.target.result;         //加载图片获取图片真实宽度和高度         var image = new Image();         image.οnlοad=function(){             var width= image.width;             var height= image.height;             ;         };         image.src= data;     };     reader.readAsDataURL(f); }
转载请注明原文地址: https://www.6miu.com/read-75746.html

最新回复(0)