[微信小程序]云开发,上传文件,设置设置路经 [你这是怎么了?]

云开发,上传文件,设置设置路经

chooseOneImage(e) {

    var that =this

    wx.chooseImage({

      count: 1,

      // sizeType: ['original '], // 可以指定是原图还是压缩图,默认二者都有

      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有

      success: function (res) {

     

      

        const filePath = res.tempFilePaths[0]


        console.log(filePath)

        // 上传图片

        const cloudPath = 'my-image' + filePath.match(/.[^.]+?$/)[0]

        console.log('cloudPath>>',cloudPath)


        wx.cloud.uploadFile({

          cloudPath,

          filePath,

          success: res => {

            console.log('[上传文件] 成功:', res)

            console.log(res.fileID)

            console.log(cloudPath)

            console.log(filePath)

            app.globalData.fileID = res.fileID

            app.globalData.cloudPath = cloudPath

            app.globalData.imagePath = filePath


打开相册的代码,怎么样才能上传到我指字的路经  我的环境/目录A /目录A子目录现在网上的代码都是环境的根据下了

  • const cloudPath = "myshare/BgPic/"+'my-image' + filePath.match(/.[^.]+?$/)[0], 怎么能是0呢?
  • 谢谢,我找也找到了,实验出来了。 , 不用客气啦,你真是个懂礼貌的好孩子