-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload.htm
42 lines (38 loc) · 1.25 KB
/
upload.htm
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
<!doctype html>
<html lang='en'>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Upload</title>
</head>
<body style="width:300px">
<h1>Upload</h1>
<div id='zone' style='width:260px;height:5em;padding:20px;background-color:#ddd'>Drop here</div>
<a href='#i'>I-Upload</a>
<hr>
<p style="text-align: right;"><a href="/microide.htm">>>></a></p>
<script>
// allow drag&drop of file objects
function dragHelper(e) {
e.stopPropagation();
e.preventDefault();
}
// allow drag&drop of file objects
function dropped(e) {
dragHelper(e);
var fls = e.dataTransfer.files;
var formData = new FormData();
var r = '/' + (location.hash ? location.hash.substring(1) + '/' : '')
for (var i = 0; i < fls.length; i++) {
formData.append('file', fls[i], r + fls[i].name);
}
fetch('/', { method: 'POST', body: formData }).then(function() {
window.alert('done.');
});
}
var zoneObj = document.getElementById('zone');
zoneObj.addEventListener('dragenter', dragHelper, false);
zoneObj.addEventListener('dragover', dragHelper, false);
zoneObj.addEventListener('drop', dropped, false);
</script>
</body>