From 745ac95fe31146ce19726a80c9b0893fa9e63fb9 Mon Sep 17 00:00:00 2001 From: Lavnish Date: Thu, 27 Nov 2025 15:50:14 +0530 Subject: [PATCH] fix: confusing message display when upload size was greater than the limit --- src/app/upload/page.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/app/upload/page.tsx b/src/app/upload/page.tsx index d847dcb..18533bb 100644 --- a/src/app/upload/page.tsx +++ b/src/app/upload/page.tsx @@ -136,6 +136,15 @@ 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), @@ -143,7 +152,7 @@ export default function Page() { 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;