文件上传在模拟器中是可以上传的,但是在真机却有时不可以?
发布于 5 年前 作者 fzhong 20157 次浏览 来自 问答

文件上传在模拟器中是可以上传的,但是在真机却有时不可以?

3 回复

域名添加了不?请求的域名有添加到白名单中了吗?

域名是有添加到白名单中的,但是就是有的时候可以有不可以,不是每次扫码都可以。

代码是:

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);

}

})

回到顶部