Can I have an HTML drag-and-drop input in Microsof

2020-02-03 06:30发布

问题:

We are adapting our product to Microsoft Edge. We have an HTML drag-and-drop feature that works correctly in IE, Chrome, etc.

Using Microsoft Edge from Win10 Insider Preview Build 10162, the drop is forbidden. We also checked http://html5demos.com/dnd-upload doesn't work neither.

Has anyone solved this problem?

回答1:

Microsoft implemented this feature in EdgeHTML 13, included in Windows 10 Build 10586 (November 2015).


Original answer:

The DragAndDropEntries is not supported in Microsoft Edge yet. See this link for more detail

It says:

Allows dragging and dropping entire folders using HTML5 Drag and Drop. Extends the DataTransferItem with a method to get a FileEntry/DirectoryEntry. Roadmap Priority: Low — We are still evaluating this technology. There may be significant spec stabilization, foundational work, or additional community input required before we can begin development."

However, feel free to request for this feature at https://wpdev.uservoice.com/forums/257854-microsoft-edge-developer



回答2:

I just tried it the demo on Microsoft Edge and it worked fine for me.



回答3:

Worked for me:

html:

<input
    id = "dropzone"
    accept = "image/*"
    multiple = "false"
    type = "file"
/>

used javaScript 'drop' event :

const dropzone = document.getElementById('dropzone');

dropzone.addEventListener('drop', (event) => { /* your callback */ })

to get file used:

event.dataTransfer.files[0]