Skip to content

Commit ebb6683

Browse files
Merge pull request #420 from BrainNotFoundException/Lavnish/UploadSizeFix
fix: confusing message display when upload size was greater than the …
2 parents be3f0b9 + 745ac95 commit ebb6683

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/app/upload/page.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,23 @@ export default function Page() {
136136
return;
137137
}
138138

139+
const totalSize = allFiles.reduce(
140+
(sum, f) => sum + f.size,
141+
0,
142+
);
143+
if (totalSize > maxFileSize){
144+
toast.error("The total upload size exceeds 5MB.", { id: toastId });
145+
return;
146+
}
147+
139148
const invalidFiles = acceptedFiles.filter(
140149
(file) =>
141150
file.size > maxFileSize || !allowedFileTypes.includes(file.type),
142151
);
143152

144153
if (invalidFiles.length > 0) {
145154
toast.error(
146-
"Some files are invalid. Make sure each is under 5MB and of allowed types (PDF, JPEG, PNG, GIF).",
155+
"Some files are invalid. Make sure the total size is below 5MB and files are of allowed types (PDF, JPEG, PNG, GIF).",
147156
{ id: toastId },
148157
);
149158
return;

0 commit comments

Comments
 (0)