代码是:
wx.uploadFile({
url: ‘https://wx.ricksha.net/wxgetredpacket/sendRedPacket’,
filePath: obj.voicePath,
name: ‘file’,
formData: {
‘openid’: that.data.openid,
‘nickName’: that.data.nickName,
‘avatarUrl’: that.data.avatarUrl,
‘answer’: obj.answer,
‘money’: obj.allMoney,
‘leaveMoney’: obj.allMoney,
‘number’: obj.number,
‘leaveNum’: obj.number,
‘voice’: obj.voicePath,
‘voiceTime’: that.data.voiceTime,
‘changeVoice’: obj.changeVoice + “”
},
success: function (res) {
var result = res.data;
console.log(“成功上传文件内容”);
if (result != “fail”) {
var rpid = result;
wx.navigateTo({
url: “/pages/getredpacket/sharepage?rpid=” + result
})
} else {
console.log(“失败文件”);
}
},
fail: function (res) {
console.log(“上传文件失败”);
console.log(res);
}
})