77 lines
2.3 KiB
HTML
77 lines
2.3 KiB
HTML
<html>
|
|
<head>
|
|
<title>Lair Tremporary Storage</title>
|
|
<meta charset="utf-8" />
|
|
<link rel="stylesheet" href="/etc/simple.css" />
|
|
</head>
|
|
<body>
|
|
<h1>Lair Tremporary Storage</h1>
|
|
<section>
|
|
<h2>Welcome</h2>
|
|
<p>
|
|
Welcome to The Lair's temporary storage service. Use this service to transport files via
|
|
a temporary remote storage. <br />
|
|
ONLY WHITELISTED USERS can upload! For access, reach out to <a href="mailto:kamkow256@gmail.com">me</a>.<br />
|
|
Only 30PLN / 12MON.
|
|
</p>
|
|
</section>
|
|
<section>
|
|
<h2>Upload</h2>
|
|
<p>
|
|
<form id="upload-form" method="POST" enctype="multipart/form-data">
|
|
<input type="file" name="myfile" id="myfile" required />
|
|
<input type="text" name="user" id="user" required />
|
|
<input type="password" name="pass", id="pass" required />
|
|
<input type="submit" value="Upload" />
|
|
</form>
|
|
</p>
|
|
</section>
|
|
<section>
|
|
<h2>Browse</h2>
|
|
<p>
|
|
Browse the files <a href="/browse">here</a>
|
|
</p>
|
|
</section>
|
|
<script>
|
|
let upload_form = document.getElementById("upload-form");
|
|
upload_form.addEventListener("submit", async function (event) {
|
|
event.preventDefault();
|
|
|
|
const file_input = document.getElementById("myfile");
|
|
const file = file_input.files[0];
|
|
if (!file) {
|
|
alert("Select a file");
|
|
return;
|
|
}
|
|
|
|
const form_data = new FormData();
|
|
form_data.append("myfile", file);
|
|
|
|
const user = document.getElementById("user").value;
|
|
const pass = document.getElementById("pass").value;
|
|
|
|
console.log(form_data);
|
|
console.log(user, pass);
|
|
|
|
const auth = "Basic " + btoa(user + ":" + pass);
|
|
|
|
try {
|
|
const host = window.location.origin;
|
|
const res = await fetch(host + "/upload", {
|
|
method: "POST",
|
|
headers: {
|
|
"Authorization": auth,
|
|
},
|
|
body: form_data,
|
|
});
|
|
|
|
const text = await res.text();
|
|
alert(text);
|
|
} catch (err) {
|
|
alert("Error: " + err);
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|