收藏
回答

小程序中上传照片是不是必须要使用wx.uploadFile 组件?

现在后台说提供了上传接口,不走wx.uploadFile 组件上传图片,请问是否能行得通?

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

5 个回答

  • 大熊
    大熊
    2023-07-14

    把官方示例代码甩他脸上

    //https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/wx.uploadFile.html
    wx.chooseImage({
      success (res) {
        const tempFilePaths = res.tempFilePaths
        wx.uploadFile({
          url: 'https://example.weixin.qq.com/upload', //仅为示例,非真实的接口地址
          filePath: tempFilePaths[0],
          name: 'file',
          formData: {
            'user': 'test'
          },
          success (res){
            const data = res.data
            //do something
          }
        })
      }
    })
    


    2023-07-14
    有用 2
    回复
  • 睡前原谅一切
    睡前原谅一切
    2023-07-14

    就是他提供接口,你用wx.uploadFile调用,不是wx.request

    2023-07-14
    有用 1
    回复
  • A🌈小韩
    A🌈小韩
    2023-07-14
    //https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/wx.uploadFile.html
    wx.chooseImage({
      success (res) {
        const tempFilePaths = res.tempFilePaths
        wx.uploadFile({
          url: 'https://example.weixin.qq.com/upload', //仅为示例,非真实的接口地址
          filePath: tempFilePaths[0],
          name: 'file',
          formData: {
            'user': 'test'
          },
          success (res){
            const data = res.data
            //do something
          }
        })
      }
    })
    
    2023-07-14
    有用 1
    回复
  • Ding
    Ding
    2023-07-14

    uploadFile  就是调用你们后台的上传接口

    2023-07-14
    有用 1
    回复 2
    • highshun
      highshun
      发表于移动端
      2023-07-14
      我觉得也是这样啊,后台说不用,搞不懂
      2023-07-14
      回复
    • Ding
      Ding
      2023-07-14回复highshun
      拿出你跑通的代码,去打他的脸
      2023-07-14
      回复
  • momo
    momo
    2023-07-14

    wx.uploadFile  url调用你们后台的上传接口,如果需要加token可以加上header头部

    2023-07-14
    有用
    回复
登录 后发表内容