• 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    미해결

[0] TypeError: Cannot read property 'path' of undefined

21.09.20 17:28 작성 조회수 213

0

안녕하세요!
5분 40초쯤 파일을 업로드하고
아래와 같은 에러가 출력됩니다.
확인 부탁 드립니다.

[0] MongoDB Connected...

[0] C:\Users\User\Desktop\boilerplate-mern-stack-master\server\routes\product.js:28

[0]       return res.json({success:true, filePath:res.req.file.path, fileName: res.req.file.filename})

[0]                                                            ^

[0]

[0] TypeError: Cannot read property 'path' of undefined

[0]     at C:\Users\User\Desktop\boilerplate-mern-stack-master\server\routes\product.js:28:60       

[0]     at Array.<anonymous> (C:\Users\User\Desktop\node_modules\multer\lib\make-middleware.js:53:37)

[0]     at listener (C:\Users\User\Desktop\node_modules\on-finished\index.js:169:15)

[0]     at onFinish (C:\Users\User\Desktop\node_modules\on-finished\index.js:100:5)

[0]     at callback (C:\Users\User\Desktop\node_modules\ee-first\index.js:55:10)

[0]     at IncomingMessage.onevent (C:\Users\User\Desktop\node_modules\ee-first\index.js:93:5)      

[0]     at IncomingMessage.emit (events.js:412:35)

[0]     at endReadableNT (internal/streams/readable.js:1317:12)

[0]     at processTicksAndRejections (internal/process/task_queues.js:82:21)

[1] [HPM] Error occurred while trying to proxy request /api/product/image from localhost:3000 to http://localhost:5000 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)    

[0] [nodemon] app crashed - waiting for file changes before starting...

[1] [HPM] Error occurred while trying to proxy request /api/product/image from localhost:3000 to http://localhost:5000 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)  

 

답변 1

답변을 작성해보세요.

0

안녕하세요  

이미지가 업로드 폴더에 잘 들어갔는지 먼저 확인해주실래요? 

업로드를 한 후 그 경로가 

res.req.file.path

일로 들어가는데 아마 업로드가 잘못되서 여기에 경로가 안들어가서 그런것 같습니다.

영래님의 프로필

영래

질문자

2021.09.23

안녕하세요!

이부분 말씀하시는거죠? 

routes/product파일로 가는게 아닌가요?