Is there a way to abort/cancel file transfer after onDrop event in Javascript, if invalid file type is selected/dropped onto the drop area?
For instance, if only .jpg, .png file formats are allowed, but the user drags and drops onto the drop area a file that has a *.gif extension I would like to cancel automatically sending/uploading data to the server and notify that an invalid file format is selected?
simple example
div = document.getElementById('div');
div.ondragover = function(event){
div.ondrop = function(event){
if(event.dataTransfer.files[0].type == 'gif'){
abort/cencel upload here
}
}
return false;//cancelling ondragover to allow ondrop event
}