2016-02-29 56 views
0

我在MEAN棧中使用了Multer。 我想用一些文本字段上傳文件。 使用郵遞員通過字段和值從「表單數據」傳遞數據。 問題是當我同時傳遞文本字段和文件時,req.body在「文件」字段之前獲得了所有值,但在文件字段之後沒有獲得任何值。當我上傳文件時,req.body變空了

+0

使用multer的一些例子中,你是否嘗試過''ENCTYPE = 「的multipart/form-data的」''? – styopdev

+0

{ 「status」:「ERROR」, 「error_message」:「Error:Multipart:Boundary not found」 } –

回答

0

有快遞 https://github.com/expressjs/multer

app.post('/profile', upload.single('avatar'), function (req, res, next) { 
// req.file is the `avatar` file 
// req.body will hold the text fields, if there were any 
}) 
相關問題