wx.chooseMessageFile
wx.chooseMessageFile({
count: 1,
type: 'file',
success(res) {
const tempFilePaths = res.tempFiles;
console.log(res, 'res', tempFilePaths, 'template');
wx.uploadFile({
url: UPDATEFILEURL, // 仅为示例,非真实的接口地址
filePath: tempFilePaths[0].path,
name: 'resume',
formData: {
resumeId: that.data.resume_id,
file_name: tempFilePaths[0].name
},
header: {
cookie: wx.getStorageSync("cookie"),
},
success(res) {
const data = res.data;
console.log(res, '成功');
res = JSON.parse(res.data)
if (res.result == 'success') {
that.getAjax(true);
$Toast({
content: '上传成功',
type: 'success'
});
} else {
$Toast({
content: res.message,
type: 'error'
})
}
// do something
},
fail(res) {
console.log(res, '失败');
}
})
},
fail(res) {
console.log(res, '选择文件失败');
}
})
2 回复
麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)