wx.chooseMessageFile 调用出现暂不支持当前功能?
发布于 6 年前 作者 chao96 14718 次浏览 来自 问答

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();
        });
      },
    });
  },

1 回复

谢邀。

全文搜索一下:暂不支持当前功能。看上去象是你自己写的代码。

回到顶部