rowanwins / vue-dropzone

A Vue.js component for Dropzone.js - a drag’n’drop file uploads utility with image previews
https://rowanwins.github.io/vue-dropzone/docs/dist
MIT License
2.02k stars 1.4k forks source link

vdropzone-file-added Triggering before validating the image #597

Open nithinkvarrier opened 3 years ago

nithinkvarrier commented 3 years ago

I had created a function onImageAdded() in vdropzone-file-added event

async onCoverImageAdded(upload) {

      console.log(upload);
     console.log(upload.accepted);

      if (upload.accepted) {
      console.log('valid image');
      }else{
console.log('Invalid image');
}

}

here upload.accepted condition always return undefined. But within a fraction of seconds 'upload' data got updated to accepted = true. If I'm adding setTimeout before the code it's working perfectly. Just like this

async onCoverImageAdded(upload) {
     setTimeout(async function() {
      console.log(upload);
     console.log(upload.accepted);

      if (upload.accepted) {
      console.log('valid image');
      }else{
console.log('Invalid image');
}
}, 0);
}

How do I validate an image is valid before moving this into server?

i-m-soumya commented 3 years ago

Facing the same issue. Any solution?