header必须带参数:
enctype="multipart/form-data";method="POST"
微信小程序,具体如下:
var _url = "";
var _header = {
'enctype':'multipart/form-data',
'method':'POST',
sessionId: '',
auth_code: ''
}
wx.uploadFile({
url: _url,
filePath: _filePath,
name: "photo",
timeout: 60000,
header: _header, // 设置请求的 header
formData: {}, // HTTP 请求中其他额外的 form data
success: function (res) {
console.log(res);
},
fail: function (res) {
that.setData({"load.hidden": true,});
},
complete: function (res) {
//console.log("over");
}
});