Helo. i want to check my input file type if it's jpg or not. i worked with 'vee-validate', which it was fine, but what i like to do is like what I've did with file size base on a tutorial.
Here's the code:
<input type="file" @change="updateMelliCodeFrontScan" name="mellicode_front_url" class="form-input" >
Here's the Vue method:
updateMelliCodeFrontScan(e){
// console.log('uploading');
let file = e.target.files[0];
let reader = new FileReader();
// let vm = this;
if (file['size'] < 200000){
reader.onloadend = (file) => {
// console.log('RESULT', reader.result)
this.form.mellicode_front_url = reader.result;
}
reader.readAsDataURL(file);
}else
{
swal({
type: 'error',
title: 'Size limited.',
text: 'size limit',
})
}
},
so i want to do it like this:
=> i want to make another if for file type base on extension/type like file['type'].
i used file['type'] === jpg and didn't worked.
if (file['size'] < 200000){
reader.onloadend = (file) => {
// console.log('RESULT', reader.result)
this.form.mellicode_front_url = reader.result;
}
reader.readAsDataURL(file);
}else
{
swal({
type: 'error',
title: 'Size limited.',
text: 'size limit',
})
}