Modernizr provides a way to detect if browser has support for drag and drop, but it fails to adequately tell if browser supports drag and drop for files. Is it possible to feature test this? Or it's kind of thing that still requires browser sniffing?
use Modernizr.filereader to detect
dataTransfer is one of the undetectables as not all browsers expose it (like webkit) so detecting if FileReader should do the trick. And i cant remember which browser it was in (android/safari etc) but the file was exposed in target.files instead of dataTransfer.files so detection if the object actually exists while in the firing event is best.
if( typeof(e.dataTransfer) !== 'undefined' && typeof(e.dataTransfer.files) !== 'undefined' ) {
files = e.dataTransfer.files;
} else if( typeof(e.target.files) !== 'undefined') {
files = e.target.files;
} else {
//Bail out
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With