收藏
回答

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

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

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子目录 现在网上的代码都是环境的根据下了

回答关注问题邀请回答
收藏

2 个回答

  • 许亮亮
    许亮亮
    2019-02-26

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

    2019-02-26
    有用 1
    回复
  • 2019-02-26

    谢谢,我找也找到了,实验出来了。


    2019-02-26
    有用
    回复 3
    • 嵩韦伟
      嵩韦伟
      2020-05-04
      你好,我也遇到了这个问题,请问怎样才能上传到指定目录下呢
      2020-05-04
      回复
    • 嵩韦伟
      嵩韦伟
      2020-05-04
      可以了,不过文件名还没改过来
      2020-05-04
      回复
    • 嵩韦伟
      嵩韦伟
      2020-05-04
      都可以了,该进行下一步插入数据库了
      2020-05-04
      回复
登录 后发表内容