上传文件时,未定义Multer req.file?

时间:2016-06-23 06:29:55

标签: iphone node.js multer

我正在尝试从iOS上传图片来源NSUrlsession。

我不知道为什么node.js不起作用但php工作正常。 在node.js

app.post('/user/account/avatar', upload.single('avatar.png'), function (req, res, next) {
  // req.file is the `avatar` file
  // req.body will hold the text fields, if there were any
       console.log(req.file);
       console.log(req.files);
       console.log('body:', req.body);
})

控制台日志:

undefined
undefined
body: { '--Boundary-D60C5F57-4786-413C-98B4-9FC89270E1E9\r\nContent-Disposition: form-data; name': '/Users/liyan/Library/Developer/CoreSimulator/Devices/9D529FFD-DB9B-43A3-BA5C-0E4ED346CC00/data/Containers/Data/Application/BCDFF115-EF53-46B7-8FF9-A5A5A87DB046/Documents/avatar.png;filename=avatar.png\r\nContent-Type: image/png\r\n\r\n\r\n--Boundary-D60C5F57-4786-413C-98B4-9FC89270E1E9--\r\n' }

0 个答案:

没有答案