fix: add file type check

This commit is contained in:
Emnaghz
2024-10-07 17:50:46 +01:00
parent e0dd09d491
commit 1d72732fad
3 changed files with 15 additions and 2 deletions

View File

@@ -99,6 +99,17 @@ const AttachmentUploader: FC<FileUploadProps> = ({
const file = event.target.files.item(0);
if (file) {
const acceptedTypes = accept.split(',');
const isValidType = acceptedTypes.some((type) =>
file.type === type || file.name.endsWith(type.replace('.*', ''))
);
if (!isValidType) {
toast.error(t("message.invalid_file_type"));
return;
}
uploadAttachment(file);
}
}