图片上传获取图片基本信息(原始分辨率等)
在这里使用了vue+element ui,在el-upload标签中的beforeupload方法,在文件上传前进行信息获取,进行校验并拦截
beforeUpload(file) {
console.log(file)
return new Promise((resolve, reject) => {
const url = window.URL || window.webkitURL
const img = new Image()
img.onload = function() {
file.width = img.width
file.height = img.height
}
img.src = url.createObjectURL(file)
resolve()
}).then(
() => {
this.fileList.push(file)
}
)
}