Skip to content

Commit

Permalink
fix(course): handle image size error
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitmlesmagico committed Apr 12, 2024
1 parent a96c09f commit cab9ac2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/inputtag/ImageUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Image from 'next/image';
import React, { MutableRefObject, useRef } from 'react';
import { FiUpload } from 'react-icons/fi';
import { RiDeleteBin5Fill } from 'react-icons/ri';
import { toast } from 'react-toastify';

import { fileToBase64Image } from '@/lib/helper';

Expand All @@ -28,6 +29,10 @@ const ImageUpload = ({
};

async function readImage(file: File) {
if (file.size > 5 * 1024 * 1024) {
toast.error('Maximum file size exceeded (5 MB)');
return;
}
onChange(file);
fileToBase64Image(file, handleImage);
}
Expand Down

0 comments on commit cab9ac2

Please sign in to comment.