【发布时间】:2018-01-11 15:51:58
【问题描述】:
我有一个 NodeJS rest-API,它在同一个函数中接受图像和文本等内容。
我在我的 NodeJS 服务器中使用 multer 来处理图像,更准确地说,我在下面有相同的示例,只是我也有内容。
var cpUpload = upload.fields([{ name: 'avatar', maxCount: 1 }, { name: 'gallery', maxCount: 8 }])
app.post('/cool-profile', cpUpload, function (req, res, next) {
// req.files is an object (String -> Array) where fieldname is the key, and the value is array of files
//
// e.g.
// req.files['avatar'][0] -> File
// req.files['gallery'] -> Array
//
// req.body will contain the text fields, if there were any
})
如何将来自 Angular 4 前端页面的图像发送到 NodeJS 后端。
谢谢!
【问题讨论】:
标签: javascript node.js angular express multer