例如下面的代码是微信小程序上传图片的代码:

wx.chooseImage({  success: function(res) {    var tempFilePaths = res.tempFilePaths    wx.uploadFile({      url: 'https://example.weixin.qq.com/upload', //仅为示例,非真实的接口地址      filePath: tempFilePaths[0],      name: 'file',      formData:{        'user': 'test',        'new_file_name': '新名字'      },      success: function(res){        var data = res.data        //do something      }    })  }})

formData参数是HTTP 请求中其他额外的 form data。但是后台php服务器怎么获取里面数据。

可以简单的使用POST获取到,例如:

$_POST[“user”]获取到的就是test,
$_POST[“new_file_name”]获取到的就是新名字。

TAG标签: 微信小程序formdata

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