Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/app/upload/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,23 @@ export default function Page() {
return;
}

const totalSize = allFiles.reduce(
(sum, f) => sum + f.size,
0,
);
if (totalSize > maxFileSize){
toast.error("The total upload size exceeds 5MB.", { id: toastId });
return;
}

const invalidFiles = acceptedFiles.filter(
(file) =>
file.size > maxFileSize || !allowedFileTypes.includes(file.type),
);

if (invalidFiles.length > 0) {
toast.error(
"Some files are invalid. Make sure each is under 5MB and of allowed types (PDF, JPEG, PNG, GIF).",
"Some files are invalid. Make sure the total size is below 5MB and files are of allowed types (PDF, JPEG, PNG, GIF).",
{ id: toastId },
);
return;
Expand Down