
Node.js 에서 index.ejs(프론트 화면) 에서 multer객체를 이용한 파일 전송을 하다가 백엔드에 연결을 하였는데
Cannot POST /upload/array
라는 에러가 떴다.
index.ejs
<h2>Multi file upload</h2>
<form action="/upload/array" method="post" enctype="multipart/form-data">
<input type="file" name="userfiles" multiple>
<input type="text" name="title"><br>
<button type="submit">Multi file 업로드</button>
</form>
원인은 아주 간단하였다.
post 메서드에서 받을 인자에 / 를 붙이지 않아서 나는 에러였음..

app.js
app.post('/upload/array', uploadDetail.array('userfiles'),(req,res)=>{
console.log(req.body); //{ title: '파일2개테스트' }
console.log(req.files); // [{},{}] 배열로 각 파일정보 저장
res.send('Success upload multiple files')
})
붙이니까 잘 된다 !

Cannot POST /a/b/c 에러의 99%는 오타라고 하니, 코드를 잘 확인해보자 !