wx.uploadFile 安卓报错 uploadFile:fail null
发布于 5 年前 作者 na51 330 次浏览 来自 问答

wx.uploadFile 在IOS中能够正常上传图片,但是在android中报 uploadFile:fail null 错。

filePath 是通过wx.chooseImage获取到的

return new Promise((resolve, reject) => {

wx.uploadFile({

url: url,

filePath: filePath,

name: ‘file1’,

formData: {},

header: { “Content-Type”: “multipart/form-data” },

success: function (res) {

if (res.statusCode == 200) {

var data = JSON.parse(res.data);

if (data.code == 0) {

resolve(data);

} else {

wx.hideLoading();

if (reject != null) {

reject(data);

}

}

} else {

wx.hideLoading();

reject(data);

}

},

fail: function (res) {

console.log(JSON.stringify(res))

var data = JSON.parse(res.data);

reject(data);

}

});

});

1 回复

求官方答案

回到顶部