微信小程序学习笔记(三):wx.uploadFile

      wx.uploadFile({
        url: 'http://192.168.1.104:80/receive',//请求数据接口地址
        filePath: '',//http路径,字符串,非数组
        name: 'file',
        header: {
          "Content-Type": "multipart/form-data"
        },
        formData: {
          method: 'POST'
        },
        success: function (res) {
          var data = res.data
          if (data == '1') {
            wx.showToast({
              title: '上传成功'
            })
          }
        },
      });

在图片上传中:
此功能只能上传一张
可以使用for循环对数组中所有图片进行上传
filePath中,应为string字符串,若为数组形式则失败([’****’])
formData和header中均可携带自定义数据标识

发布了71 篇原创文章 · 获赞 204 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/qq_44198436/article/details/104110525