js在前端获取在本地上传图片的尺寸


var MyTest = document.getElementById("upload_img").files[0];
var reader = new FileReader(); reader.readAsDataURL(MyTest); reader.onload = function(theFile) {   var image = new Image(); image.src = theFile.target.result; image.onload = function() {   alert("图片的宽度为"+this.width+",长度为"+this.height); }; };

其中,id为“upload_img”的标签如下:

<input type="file" size="20" autocomplete="off" id="upload_img" name="Uploadfile">

 

  程序猿必读


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM