Use return false
or e.preventDefault();
to disable the default action:
$('input[type=file]').on('drop', function(e) {
if (!confirm("are you sure?")) {
e.preventDefault();
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="file" name="test">
Unfortunately, this is apparently not portable. It works in Chrome and Safari, but not FireFox (I'm on a Mac and haven't tried IE).
A portable solution would have to use an HTML modal dialogue to get the confirmation. The cancellation callback can then use the technique in Clearing <input type='file' /> using jQuery to remove the dropped file from the input.