I have a code in Vuejs that it uploads a image but I need to check the width and height of that image I have my code like this:
This is my input :
<input ref="file" accept="image/png" type="file" class="form-control" v-on:change="onFileChange" required>
This is a method that I use to upload when select the image :
onFileChange(e){
this.file = e.target.files[0];
this.noFile = e.target.files.length;
},
This is my code to upload :
onSubmit(e) {
this.loading = true; //the loading begin
e.preventDefault();
let currentObj = this;
const config = {
headers: { 'content-type': 'multipart/form-data' }
}
axios.post('/api/section/store?api_token='+App.apiToken, formData, config)
.then(function (response) {
currentObj.success = response.data.success;
})
.catch(function (error) {
console.log(error);
})
formData.append('file', this.file);
}
So I wonder how can I retrieve the width and height? I have tried this:
onFileChange(e){
this.file = e.target.files[0];
console.log(this.file.width);
this.noFile = e.target.files.length;
},
It says undefined, so how can I do that ?