//html
<input type="file" id="MapUploadTd" onchange="getMapPictureSize(this.files[0])"/>
//js
var mapPictureSize = [];
function getMapPictureSize(file) {
var reader = new FileReader;
reader.onload = function (evt) {
var image = new Image();
image.onload = function () {
mapPictureSize[0] = this.width + "";
mapPictureSize[1] = this.height + "";
console.log(mapPictureSize);
};
image.src = evt.target.result;
};
reader.readAsDataURL(file);
}
// vue中使用拿到file对象即可
JS获取上传图片的宽高
最新推荐文章于 2023-02-05 11:39:01 发布