在使用multer上传文件时,文件能正常上传,但报错Error: Unexpected end of form
这是改前的代码:
app.post('/upload',upload.array('file'),(req, res, next) => {
//获取文件上传后的一些信息
console.log(req.files);
res.end('文件上传成功!')
})
这是改后的代码
app.post('/upload', (req, res, next) => {
//获取文件上传后的一些信息
console.log(req.files);
res.end('文件上传成功!')
},
upload.array('file'))
参考了这里的回答:https://stackoverflow.com/questions/72887603/how-to-solve-multer-error-unexpected-end-of-form