NaKaLiGoBa / Instagram

인스타그램 클론코딩
https://nakaligoba.github.io/Instagram/
0 stars 0 forks source link

FormData 전송 오류 #48

Open acisliver opened 11 months ago

acisliver commented 11 months ago

WriteModal.js에서 이미지를 업로드 핸들러 함수입니다.

const handleOnImgUpload = async (e) => {
  if (!e.target.files) {
    return;
  }

  setState({
    ...state,
    files: e.target.files,
    preView: URL.createObjectURL(e.target.files[0]),
  });
};

setState를 보면 62번째 줄에서 filese.target.files를 설정해주는데 이를 e.target.files[0]으로 변경해야 합니다!

setState({
  ...state,
  files: e.target.files[0],
  preView: URL.createObjectURL(e.target.files[0]),
});
mintmin0320 commented 11 months ago

이미지를 여러 장 업로드 하려고 리스트 자체를 저장 했었는데, e.target.files[0]으로 지정하면 사진을 한 장 밖에 못 보내지 않나요??