html52.com
我爱小程序-开发者交流社区

wx.chooseMessageFile ,pdf文件选择失败?

wx.chooseMessageFile({

count: that.maxcont,

type: 'file', // 可以选all

success(res) {

// tempFilePath可以作为 img 标签的 src 属性显示图片

// const tempFilePaths = res.tempFiles

const tempFilePaths = res.tempFiles

let rad = new Date().getTime();

console.log("微信文件路径tempFilePaths", tempFilePaths)

let paramList = []

for(var j=0;j<tempFilePaths.length;j++){

paramList.push({

url: that.fileApiUrl, //替换为你的接口地址

name: 'file'+rad, // 附件key

debug: true,

//根据你接口需求自定义请求头

header: that.headerUp,

//根据你接口需求自定义body参数

formData: that.otherdata

})

}

// file和参数一一对应处理

tempFilePaths.forEach(function(fileEle, fileIndex) {

console.log(fileEle, fileIndex)

let fileParam = paramList[fileIndex] || {}

let fileInfoEle = {

file: fileEle,

param: fileParam

}

that.fileLi.push(fileInfoEle)

})

},

fail(err) {

console.log('文件报错', err)

},

})

预览 的时候 ,手机选择pdf 文件 选择失败,word可以,excel个别可以,个别不行 基础库 2.30.2

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付