wx.chooseMessageFile,手机型号:mate20,微信版本8.0.3
wxml
<view class="doc-select-item" catch:tap="uploadDoc">从微信聊天中选择文档</view>
js
uploadDoc() {
wx.chooseMessageFile({
count: 1,
type: "file",
extension: ["doc", "ppt", "xls", "xlsx", "docx", "pdf", "pptx"],
success: (res) => {
wx.showLoading({ mask: true, title: "正在上传..." });
let filePath = res.tempFiles[0].path;
let userFileName = res.tempFiles[0].name;
let fileName =
"/miniapp/doc/" +
uuidTime() +
"/" +
uuid() +
filePath.substring(filePath.indexOf("."));
upload(fileName, filePath, (data) => {
if (data.statusCode == 200) {
that.setData({
type: 4,
uploadType: 4,
docUrl: "https://" + data.Location,
docName: userFileName,
ossKeyName: data.ETag.substring(1, data.ETag.lastIndexOf('"')),
savePath: "https://" + data.Location,
});
that.closeDocSelect();
}
wx.hideLoading();
});
},
});
},
请问解决了吗
你好,extension这个设置了,但是不生效,也没有报错,上传文件还是能选择其他类型的,要设置其他参数吗?
谢邀。
全文搜索一下:暂不支持当前功能。看上去象是你自己写的代码。