From cef46aa5f5b9cac5c43bd842ed64580357718e86 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sun, 21 May 2023 13:45:15 +0200 Subject: implement the upload backend --- web/client.html | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'web') diff --git a/web/client.html b/web/client.html index 87ca51a..a330c00 100644 --- a/web/client.html +++ b/web/client.html @@ -237,6 +237,18 @@ return false; } + {{if .HasUpload}} + function submitUpload() { + const form = new FormData(document.getElementById("uploadForm")); + const file = form.get("song"); + const params = new URLSearchParams(); + params.append("song", file.name); + const song = params.toString(); + new HttpClient().post("/upload?" + song, file, console.log); + return false; + } + {{end}} + function addSong(song) { new HttpClient().post("/add", JSON.stringify(song), console.log); } @@ -282,6 +294,13 @@ + + {{if .HasUpload}} +
+ + +
+ {{end}}