Question

While Dragging and Dropping a file from disk to an input box, "change" event does not get fired for input type='file' element. The same code works for other major browsers but does not work in Firefox 15 and above.

    $("input[type='file']").change(
        function(){
            // Do form submit
        }
    );

A hack-ish way to achieve the same is by using setTimeout and HTML5 'drop' event.

    $("input[type='file']").on('drop',function(event){
        this.files = event.originalEvent.dataTransfer.files;
        setTimeout(function(){
            //  Do form submit
        }, 0);  // Note that the timeout is 0ms
    });

Not sure if this is the best way to go about it...

PS: Without using setTimeout(..) and submitting the form directly does not work in FF 15+

Was it helpful?

Solution

Looks like https://bugzilla.mozilla.org/show_bug.cgi?id=786172 for what it's worth.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top