Skip to content

Commit 1c374a0

Browse files
committed
fix: add duplicate file check in Dropzone component to prevent re-selection
1 parent 0916a21 commit 1c374a0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

adminforth/spa/src/afcl/Dropzone.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,18 @@ function doEmit(filesIn: FileList) {
149149
const extension = file.name.split('.').pop()?.toLowerCase() || '';
150150
const size = file.size;
151151
152+
const isDuplicate = storedFiles.value.some(
153+
existingFile => existingFile.name === file.name && existingFile.size === file.size
154+
);
155+
156+
if (isDuplicate) {
157+
adminforth.alert({
158+
message: `The file "${file.name}" is already selected.`,
159+
variant: 'warning',
160+
});
161+
return;
162+
}
163+
152164
if (!allowedExtensions.includes(`.${extension}`)) {
153165
adminforth.alert({
154166
message: `Sorry, the file type .${extension} is not allowed. Please upload a file with one of the following extensions: ${allowedExtensions.join(', ')}`,

0 commit comments

Comments
 (0)