From 3ff1031b19b7c1e0f46efd986202355b59713f0c Mon Sep 17 00:00:00 2001 From: joshkat Date: Thu, 25 Apr 2024 22:41:33 -0400 Subject: [PATCH] Added file upload for song --- app/home/page.jsx | 83 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 2 deletions(-) diff --git a/app/home/page.jsx b/app/home/page.jsx index 972007e..693a8cd 100644 --- a/app/home/page.jsx +++ b/app/home/page.jsx @@ -1,5 +1,84 @@ export default function Home() { + async function formAction(formData) { + "use server"; + const rawFormData = { + songTitle: formData.get("songTitle"), // this is the title + songArtist: formData.get("songArtist"), // this is the artist + songFile: formData.get("songFile"), // this is the file + }; + + // when songFile fits these params it works with it + if ( + rawFormData.songFile.size > 0 && + rawFormData.songFile.name != "undefined" && + rawFormData.songFile.type == "text/plain" && + rawFormData.songTitle.length > 0 && + rawFormData.songTitle.length > 0 + ) { + // work with file + console.log(rawFormData); + } + // otherwise throw an error + } + return ( -
this is the home page
- ) +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
+
+ ); }