-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
35 lines (33 loc) · 976 Bytes
/
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>gorecv index</title>
</head>
<body>
<form id="form">
Select file to upload:
<input type="file" name="file" id="file">
<input type="submit" value="Upload!" name="submit">
</form>
<script>
let form = document.querySelector('form');
form.addEventListener('submit', async e => {
e.preventDefault();
let filename = document.querySelector('[type=file]').value;
filename = filename.replace(/^.*[\\\/]/, '');
let file = document.querySelector('[type=file]').files[0];
let response = await fetch("/?name=" + filename, {
method: 'POST',
body: file,
});
if (!response.ok) {
let text = await response.text();
alert("Failed uploading " + filename + ": " + text);
} else {
alert("Successfully uploaded " + filename + "!");
}
})
</script>
</body>
</html>