diff --git a/client/upload.html b/client/upload.html
index bd34f5b..db4d0de 100644
--- a/client/upload.html
+++ b/client/upload.html
@@ -25,35 +25,49 @@
Upload
-
diff --git a/static/style.css b/static/style.css
index b543076..ff722f8 100644
--- a/static/style.css
+++ b/static/style.css
@@ -148,3 +148,7 @@ main section textarea,
margin: 1.5em;
}
+#form-section {
+ display: block;
+}
+
diff --git a/static/upload.js b/static/upload.js
index e3dc44d..2c88621 100644
--- a/static/upload.js
+++ b/static/upload.js
@@ -1,26 +1,43 @@
-const uploadVideoButton = document.getElementById("uploadVideoButton");
+const fileForm = document.getElementById("file-form");
const divOutput = document.getElementById("divOutput");
const video = document.getElementById("video");
-const title = document.getElementById("title");
-const description = document.getElementById("description");
-const error = document.getElementById("error");
+const titleElement = document.getElementById("title");
+const descriptionElement = document.getElementById("description");
+const fileError = document.getElementById("fileError");
+const titleError = document.getElementById("titleError");
+const descriptionError = document.getElementById("descriptionError");
+
+fileForm.addEventListener("submit", (e) => {
+ e.preventDefault()
+
+ const title = titleElement.value;
+ const description = descriptionElement.value;
+ const regex = /^[a-zA-Z0-9\s\-_',.!&():]+$/
+
+ if(!regex.test(title)) {
+ titleError.textContent = "Invalid Title";
+ titleError.style.display = "block";
+ return;
+ }
+
+ if(!regex.test(description)) {
+ descriptionError.textContent = "Invalid Description";
+ descriptionError.style.display = "block";
+ return;
+ }
-uploadVideoButton.addEventListener("click", () => {
- console.log(title.value);
- console.log(description.value);
- console.log("Read and upload button hit!");
const fileReader = new FileReader();
const theFile = video.files[0];
-
- console.log(theFile.type);
- const type = theFile.type;
+ const type = theFile.type
if(type !== "video/mp4") {
- error.textContent = "Only .mp4 files are supported";
- error.style.display = "block";
+ fileError.textContent = "Only .mp4 files are supported";
+ fileError.style.display = "block";
return;
}
- error.style.display = "none";
+ titleError.style.display = "none";
+ descriptionError.style.display = "none";
+ fileError.style.display = "none";
fileReader.onload = async (ev) => {
const CHUNK_SIZE = 20000000;
diff --git a/utils/util.go b/utils/util.go
index 67c7650..a8b9609 100644
--- a/utils/util.go
+++ b/utils/util.go
@@ -159,7 +159,6 @@ func UploadToAppwrite(folderName string, db *sql.DB) {
log.Fatal(err)
}
defer response.Body.Close()
- log.Println(response.StatusCode)
if response.StatusCode != 201 {
body, err := io.ReadAll(response.Body)
if err != nil {