Alex Rivera | Logout

How to determine presence of HTML5 drag'n'drop file upload API (like the one from FF3.6)

Asked 2010-02-22T15:25:23.623
24

I am writing an application that's supposed to support HTML5 drag/drop API for file, much like the on described here. I would like to perform a programmatic check on whether the browser support this kind of madness :) A solution that works for now is checking whether the browser provides a FileReader class, like this:

  if (typeof(FileReader) == "undefined") {
    $("#dropbox").hide();
  } else {
    // connect events
    $("#filebox").hide();
  }

But it is obviously not a correct one (I don't use that class at all).

Any ideas?

Edit
Report

1 Answer

1

This code fails in IE8. This would probably be better:

if (typeof(FileReader) === 'function' && Modernizr.draganddrop) {
  //sexy drag and drop action
} else {
   //no drag and drop support available :(
};
answered 2012-03-25T20:47:53.783

Your Answer