Untitled
unknown
plain_text
a year ago
705 B
4
Indexable
const docUploadValidation = (fileImage) => {
const maxFileSize = 4 * 1024 * 1024; // 4MB
const validImageTypes = ['image/jpeg', 'image/png', 'image/jpg'];
if (fileImage?.length > 0) {
const file = fileImage[0].file;
if (file.size > maxFileSize) {
toast.error("Image size should not exceed 4MB", { autoClose: 3000 });
return false;
}
if (!validImageTypes.includes(file.type)) {
toast.error("File type should be an image (JPEG, PNG, or JPG)", { autoClose: 3000 });
return false;
}
}
return true;
};Editor is loading...
Leave a Comment