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

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

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

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

TAG标签: 小程序上传文件至云存储小程序怎么从云空间下载文件小程序文件下载

http://www.xiaochengxub.com/read-97091.html