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

前端 未结 8 723
一生所求
一生所求 2020-12-01 04:53

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 whethe

8条回答
  •  旧时难觅i
    2020-12-01 05:28

    Checking for the existence of FileReader is the correct way to go about this. FileReader is an official part of the File Api. I would combine this with Modernizr. Drag and Drop support is slated for release 1.2. You should be able to grab the source on GitHub and start working with this now. http://github.com/Modernizr/Modernizr/blob/master/modernizr.js

    if (!!FileReader && Modernizr.draganddrop) {
      // sexy drag and drop action
    } else {
      // no drag and drop support available :(
    }
    

    If you haven't seen Dive into HTML5, you should definitely check out Mark Pilgrim's suggestions on detecting HTML5.

提交回复
热议问题