我正在尝试从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' }