1<!DOCTYPE html>
2<html>
3<body>
4<div id="dropContainer" style="border:1px solid black;height:100px;">
5 Drop Here
6</div>
7 Should update here:
8 <input type="file" id="fileInput" />
9
10
11<script>
12dropContainer.ondragover = dropContainer.ondragenter = function(evt) {
13 evt.preventDefault();
14};
15
16dropContainer.ondrop = function(evt) {
17 // pretty simple -- but not for IE :(
18 fileInput.files = evt.dataTransfer.files;
19
20 // If you want to use some of the dropped files
21 const dT = new DataTransfer();
22 dT.items.add(evt.dataTransfer.files[0]);
23 dT.items.add(evt.dataTransfer.files[3]);
24 fileInput.files = dT.files;
25
26 evt.preventDefault();
27};
28</script>
29
30</body>
31</html>
32