Skip to content

Commit

Permalink
코드리뷰 받은 에러처리, 예외처리 코드 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
kimsoyoung96 committed Dec 9, 2024
1 parent b30d603 commit c81e548
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/components/Editinput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,24 @@ const Editinput = ({ type, info, placeholder }) => {
const imgRef = useRef();

const saveImgFile = () => {
if (!imgRef.current || !imgRef.current.files[0]) {
console.error('파일이 선택되지 않았습니다.');
return;
}

const file = imgRef.current.files[0];
const reader = new FileReader();

reader.readAsDataURL(file);

reader.onloadend = () => {
setImgFile(reader.result);
if (reader.result) {
setImgFile(reader.result); // reader.result는 base64 데이터 URL
}
};

reader.onerror = () => {
console.error('파일을 읽는 도중 에러가 발생했습니다.');
};
};

Expand Down

0 comments on commit c81e548

Please sign in to comment.