-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
56 lines (38 loc) · 1.48 KB
/
index.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
52
53
54
55
56
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>HTTP File uploader</title>
</head>
<body style="font-family: monospace;">
<h2>HTTP File Uploader</h2>
<form enctype="multipart/form-data" action="/upload" method="post" id="file-upload-form">
<label for="file-upload-path">File upload path</label>
<input type="text" id="file-upload-path" name="file_upload_path" />
<input type="file" id="file-selector" name="selected_files" multiple required />
<div id="selected-files"></div>
<input type="submit" value="Upload files" style="margin-top:10px;" />
</form>
<script>
var fileSelector = document.getElementById("file-selector");
var selectedFiles = document.getElementById("selected-files");
document.getElementById("file-upload-form").reset();
function showSelectedFiles(event) {
var handlesOfSelectedFiles = event.srcElement.files;
var innerHtml = "<h3>Selected files:</h3>" +
"<ul>" +
Object.keys(handlesOfSelectedFiles)
.map(function (index, key) {
var fileHandle = handlesOfSelectedFiles[key];
return "<li>" + fileHandle.name + "</li>";
})
.join("") +
"</ul>";
selectedFiles.innerHTML = innerHtml;
}
fileSelector.addEventListener("change", showSelectedFiles);
</script>
</body>
</html>