mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: add file type check
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user