I use flow.js (doc here) to upload documents on my website.
2 ways to upload something:
- Through an 'upload' button
- By drag'n drop
I would like to ask confirmation from the user if the file is drag'n droppped.
You can take a look at the code below:
this.flow.on('fileAdded', (file, event) => {
if (event.type == 'drop') // File has been dropped
{
if (!confirm("ok?"))
this.flow.removeFile(file);
}
});
It works but it is not user friendly as you can see below:
Is there another solution? I thought about using promises and custom boxes, but so far I was not able to use a promise system in conjunction with this event handler (this.flow.on('fileAdded'...).
I don't think the fileAdded event is waiting for a promise.

If you only wanna execute this.flow.removeFile(file) if confirm dialog fails there should be no problem. Just in your case take care with "this" as the context changes inside promise handler.