blob: 220c8c9989418debe7fabbf6641fcf4944ace866 (
plain)
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
|
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>box</title>
<script>
function upload() {
f = document.getElementById("file").files[0];
const xhr = new XMLHttpRequest();
xhr.upload.addEventListener("progress", (e) => {
p = document.getElementById("progress")
ratio = e.loaded / e.total;
perc = Math.floor(ratio * 100);
p.innerHTML = perc + "%";
});
xhr.open("POST", "/" + f.name, true);
xhr.send(f)
/*const response = await fetch("/" + name, {
method: "POST",
body: f,
});*/
}
</script>
</head>
<body>
<h1>Box</h1>
<pre>Server for uploading files. Use the form here or send a POST request to /[filename] with the content of the file in the body.</pre>
<input type="file" id="file"/><br/><br/>
<button type="button" onclick="upload()">Upload</button><br/>
<span id="progress"></span>
</body>
</html>
|