[node.js] multer 파일 업로드 Unexpected field 에러

2022. 5. 15. 04:03·Trouble Shooting
반응형

🚨 문제상황

multer를 이용하여 파일을 업로드하는 코드를 실행하니 다음과 같은 에러가 떴다.

MulterError: Unexpected field
   at wrappedFileFilter (D:\study\node_modules\multer\index.js:40:19)
   at Busboy.<anonymous> (D:\study\node_modules\multer\lib\make-middleware.js:115:7)
   at Busboy.emit (node:events:520:28)
   at Busboy.emit (D:\study\node_modules\busboy\lib\main.js:38:33)
   at PartStream.<anonymous> (D:\study\node_modules\busboy\lib\types\multipart.js:213:13)
   at PartStream.emit (node:events:520:28)
   at HeaderParser.<anonymous> (D:\study\node_modules\dicer\lib\Dicer.js:51:16)
   at HeaderParser.emit (node:events:520:28)
   at HeaderParser._finish (D:\study\node_modules\dicer\lib\HeaderParser.js:68:8)
   at SBMH.<anonymous> (D:\study\node_modules\dicer\lib\HeaderParser.js:40:12)

 

🥁 해결 방법

해당 에러는 이름이 같지 않아서 생긴 문제이다.

input 태그의 name과 upload.single()의 인자가 일치해야 한다. 

 

아래의 html 파일에서 하이라이트한 부분과

아래의 js 파일에서 하이라이트 한 부분의 이름이 같아야 한다.

 

반응형

'Trouble Shooting' 카테고리의 다른 글

[Next.js] React Hydration Error  (0) 2024.10.21
[html] svg 높이 설정 에러  (0) 2024.10.21
[yarn] yarn : 이 시스템에서 스크립트를 실행할 수 없으므로 C:\Users\user\AppData\Roaming\npm\yarn.ps1 파일을 로드할 수 없습니다. 자세한 내용은 about_Execution_Policies(https://go.microsoft.com/fwlink/?LinkID=135170)를 참조하십시오.  (0) 2024.09.13
[Spring] Name for argument of type [java.lang.String] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag.  (2) 2024.04.23
'Trouble Shooting' 카테고리의 다른 글
  • [Next.js] React Hydration Error
  • [html] svg 높이 설정 에러
  • [yarn] yarn : 이 시스템에서 스크립트를 실행할 수 없으므로 C:\Users\user\AppData\Roaming\npm\yarn.ps1 파일을 로드할 수 없습니다. 자세한 내용은 about_Execution_Policies(https://go.microsoft.com/fwlink/?LinkID=135170)를 참조하십시오.
  • [Spring] Name for argument of type [java.lang.String] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag.
올콩
올콩
콩 심은 데 콩 난다
  • 올콩
    콩스토리
    올콩
  • 전체
    오늘
    어제
    • 분류 전체보기 (192) N
      • SSAFY (10)
      • Algorithm (112) N
        • 이론 (6)
        • 백준 (BOJ) (105) N
        • 프로그래머스 (1)
      • Trouble Shooting (9)
      • Frontend (6)
      • React (17)
      • Next.js (3)
      • Vue (4)
      • Node.js (2)
      • HTML (9)
      • DevOps (3)
        • Git (3)
      • Language (9)
        • JavaScript (0)
        • Java (9)
      • Embedded (1)
      • CS (5)
        • Network (1)
        • Blockchain (4)
      • 자격증 (2)
  • 블로그 메뉴

    • GitHub
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    Next.js
    백트래킹
    티스토리챌린지
    재귀
    DP
    우선순위큐
    SSAFY
    알고리즘
    html5
    중복조합
    오블완
    수학
    dfs
    싸피
    브루트포스
    bfs
    React
    파이썬
    구현
    중복순열
    Heap
    Error
    Java
    강의
    블록체인
    SSAFYcial
    힙
    백준
    순열
    Algorithm
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
올콩
[node.js] multer 파일 업로드 Unexpected field 에러
상단으로

티스토리툴바