From 69f90fb809738a571144a6ba787b0ef7a5338d4e Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Thu, 26 Feb 2026 11:31:32 +0530 Subject: [PATCH] fix: assignment upload issue --- frontend/src/components/Assignment.vue | 3 ++- frontend/src/utils/index.js | 18 ++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/Assignment.vue b/frontend/src/components/Assignment.vue index 80611b05..a521201a 100644 --- a/frontend/src/components/Assignment.vue +++ b/frontend/src/components/Assignment.vue @@ -83,7 +83,8 @@ private: true, }" :validateFile=" - (file) => validateFile(file, assignment.data.type.toLowerCase()) + (file) => + validateFile(file, true, assignment.data.type.toLowerCase()) " @success="(file) => saveSubmission(file)" > diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js index 8b994593..3f828dcf 100644 --- a/frontend/src/utils/index.js +++ b/frontend/src/utils/index.js @@ -650,21 +650,19 @@ export const validateFile = async ( console.error(msg) return msg } - if (!file.type.startsWith(`${fileType}/`)) { - return error(__('Only {0} file is allowed.').format(fileType)) - } - if (fileType == 'pdf' && extension !== 'pdf') { + if (fileType == 'pdf' && extension != 'pdf') { return error(__('Only PDF files are allowed.')) - } - - if (fileType == 'document' && !['doc', 'docx'].includes(extension)) { + } else if (fileType == 'document' && !['doc', 'docx'].includes(extension)) { return error( __('Only document file of type .doc or .docx are allowed.') ) - } - - if (file.type === 'image/svg+xml') { + } else if ( + ['image', 'video'].includes(fileType) && + !file.type.startsWith(`${fileType}/`) + ) { + return error(__('Only {0} file is allowed.').format(fileType)) + } else if (file.type === 'image/svg+xml') { const text = await file.text() const blacklist = [