maotube/public/upload/script.js

23 lines
507 B
JavaScript
Raw Normal View History

document.getElementById("upload-form").addEventListener("submit", event => {
2024-02-12 23:07:28 +00:00
event.preventDefault();
const data = new FormData(event.target);
fetch("/api/upload-video", {
2024-02-12 23:07:28 +00:00
method: "POST",
body: data,
})
.then(response => response.json())
.then(response => {
if (!response.ok) {
error(response.error);
return;
}
2024-02-12 23:07:28 +00:00
location.href = "/queue";
})
.catch(err => {
error("failed to upload video");
});
2024-02-12 23:07:28 +00:00
});