document.getElementById("uploadButton").addEventListener("click", async () => { const fileInput = document.getElementById("fileInput"); const files = Array.from(fileInput.files); if (files.length === 0) { alert("Please select some files first."); return; } const formData = new FormData(); formData.append("bounty_id", 7); files.forEach((file) => { formData.append("files", file); // Append each file to FormData }); try { const response = await fetch("http://localhost:5000/submit-solution", { method: "POST", body: formData, }); if (!response.ok) { throw new Error("Network response was not ok"); } const data = await response.json(); console.log("Upload successful:", data); } catch (error) { console.error("Error uploading files:", error); } });