CameraRoll.getPhotos(fetchParams) .then((data)=> this._appendImages(data),(e)=> console.log(e));
当我使用FormData
时const images = messages.map(k => {
return {
uri: k.image, //`file:///${k.image}`,
name: k.filename,
type: mime.lookup(k.filename),
}
})
console.log(images)
postData = new FormData();
postData.append('file', images);
postData.append('userid', this.user._id);
postData.append('time', moment().format('YYYY-M-D H:mm:ss'));
postData.append('group', this.groupID);
axios.post(WebAPI.url.chat.postImage,
postData,
{
headers: {
access_token: this.user.access_token,
'Content-Type': 'multipart/form-data',
},
}
).then(response => {
console.log(response.data)
}).catch(error => {
console.log(error)
})
C#可以获取Request.Form,但无法获取Request.Files
谁可以帮助我?非常感谢你!答案 0 :(得分:0)
哦!我的错!
postData.append('file',images); //追加文件必须一个接一个
所以改变这一点,会很好用!
messages.forEach(k => {
postData.append('file', {
uri: k.image,
name: k.filename,
type: mime.lookup(k.filename),
});
})