forked from c9/c9.ide.upload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
51 lines (40 loc) · 1.25 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html>
<head>
<title> </title>
</head>
<body>
<div id=dropzone>drop zone</div>
<input id="file" type="file" multiple />
<input id="folder" type="file" webkitdirectory directory />
<script>
function define(factory) {
main(factory(null, {}, {}));
}
function main(Batch) {
var dropzone = document.getElementById('dropzone');
var file = document.getElementById('file');
var folder = document.getElementById('folder');
file.onchange = onchange;
folder.onchange = onchange;
function onchange(e) {
Batch.fromInput(e.target, function(err, batch) {
console.log(batch.files, batch.hasDirectories(), batch.getRoots(), batch.getSizes());
});
}
dropzone.ondrop = function(evt) {
evt.stopPropagation();
evt.preventDefault();
Batch.fromDrop(evt, function(err, batch) {
console.log(batch.files, batch.hasDirectories(), batch.getRoots(), batch.getSizes());
});
};
dropzone.ondragover = function (evt) {
evt.stopPropagation();
evt.preventDefault();
evt.dataTransfer.dropEffect = 'copy';
};
}</script>
<script type="text/javascript" src="batch.js"></script>
</body>
</html>