fix: allow larger file uploads

This commit is contained in:
2025-05-30 11:42:44 +01:00
parent c5c52dc89d
commit 96e8be3543
2 changed files with 11 additions and 25 deletions

View File

@@ -15,27 +15,14 @@
async function uploadStudySpace() {
const imageFile = fileInput?.files?.[0];
const imageB64 = imageFile
? await new Promise<string>((resolve) => {
const reader = new FileReader();
reader.onload = () => resolve(reader.result as string);
reader.readAsDataURL(imageFile);
})
: null;
if (!imageB64 || !imageFile) {
if (!imageFile) {
alert("Please select an image file.");
return;
}
const res = await fetch("/api/study_spaces", {
const params = new URLSearchParams({ title, imgTitle: imageFile.name });
const res = await fetch(`/api/study_spaces?${params.toString()}`, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
title,
img: imageB64,
imgTitle: imageFile.name
})
body: imageFile
});
if (res.ok) {
alert("Study space uploaded successfully!");