描述
官方文档中介绍的上传含糊其辞,这里基于vant ui框架实现将文件上传到云存储当中
方法
home.wxml
<van-uploader accept="file" bind:after-read="afterRead">
<van-button icon="comment" type="primary">上传</van-button>
</van-uploader>
home.js
afterRead:function(e) {
console.log(e);
wx.cloud.uploadFile({
cloudPath:"course_from/" + e.detail.file.name +".xls",
filePath:e.detail.file.path,
success:res => {
console.log("上传成功")
}
})
},
cloudPath 是你文件存储到云存储当中的路径,但是没有后缀,代码中要存储的是xls文件,故加了.xls后缀
filePath 是你要上传的文件存储的路径,