1 addImg:function(){
 2     wx.chooseImage({
 3       success: function(res) {   //chooseImage方法调用成功
 4         console.log(res);
 5 
 6         wx.cloud.uploadFile({
 7           cloudPath:"funny/mbp.jpg",
 8           filePath: res.tempFilePaths[0],           
 9             success(res){     //上传至云存储后
10             console.log(res);
11           }
12         })
13       },
14     })
15   }

第四行的console.log(res)  , 打印后可以看到一个tempFilePaths数组,tempFilePaths是图片的本地临时文件路径列表

那么tempFilePaths[0]就是具体的文件路径。

 

第二个res是上传文件upLoadFile后的,打印时会看到上传成功后在云存储的fileID,如果需要用到该文件就可以直接引用它了。

 

小程序上传文件至云存储

 

相关文章:

  • 2021-12-14
  • 2021-10-14
  • 2022-01-23
  • 2022-01-25
  • 2021-11-21
  • 2021-06-11
  • 2021-06-24
  • 2021-06-27
猜你喜欢
  • 2021-11-19
  • 2022-02-10
  • 2021-11-21
  • 2022-12-23
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案