赞
踩
使用post请求向向后端Form Data格式的数据 ,小程序不能使用new FormData()?
“content-type”:"application/x-www-form-urlencoded"这么设置也可以传递
如果wx.request中仅指定’content-type’为’multipart/form-data’,服务端会报"no multipart boundary was found"的错误
解决方法前端代码如下:
wx.request({
url:‘http://localhost:8080/test/multipart-form’,
method:‘POST’,
header: {
‘content-type’:‘multipart/form-data; boundary=XXX’
},
data:’\r\n–XXX’ +
‘\r\nContent-Disposition: form-data; name=“field1”’ +
‘\r\n’ +
‘\r\nvalue1’ +
‘\r\n–XXX’ +
‘\r\nContent-Disposition: form-data; name=“field2”’ +
‘\r\n’ +
‘\r\nvalue2’ +
‘\r\n–XXX–’
})
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。