<button bindtap="chat_chooes_img">测试上传任何格式文件,从聊天窗口</button>
chat_chooes_img() {
var that = this;
wx.chooseMessageFile({
count: 1, // 默认9,这里我们设置为1,表示只选择一张图片
type: 'image', //默认 'all' 所选的文件的类型
success: function (res) {
var tempFilePaths = res.tempFiles;
uploadFile(baseURL + "/api/xcx/kecheng/type/uploadimage", tempFilePaths[0].path, "image").then(res => {
var result = JSON.parse(res.data); //
that.setData({
img: result.url
})
})
}
})
},
还有一种写法,如下。没有实验过。
wx.chooseMessageFile({
count: 1,//限制选择的文件数量
type: 'file',//非图片和视频的文件,不选默认为all
extension:['xlsx','.xlsx'],//此处限制文件类型
success (res) {
const tempFilePaths = res.tempFiles
console.log('临时路径',tempFilePaths)站长微信:xiaomao0055
站长QQ:14496453