I have an input type file
<input type="file" class="userUploadButton" name="image" accept="image/*" on-change={this.setImage}/>
and Vue - method "setImage"
setImage(e){
const file = e.target.files[0];
if (!file.type.includes('image/')) {
Vue.swal({
title: 'Error!',
text: 'This is no image',
type: 'error',
});
return;
}
if(typeof FileReader === 'function'){
const reader = new FileReader();
reader.onload = (event) => {
this.imgSrc = event.target.result;
this.$refs.cropper.replace(event.target.result);
};
reader.readAsDataURL(file);
}else{
Vue.swal({
title: 'Error',
text: 'Your browser does not support FileReader API',
type: 'error',
});
}
},
In the moment when user upload an image, I have to check width and height of this image and stop uploading (or delete the image)