微信小程序 上传项目图片

sendClick: function (e) {
wx.uploadFile({
url: 'http://***/zx/news/uploadFile', //开发者服务器的 url
filePath: '/images/img/1.jpg', // 要上传文件资源的路径 String类型!!! //项目路径
name: 'file', // 文件对应的 key ,(后台接口规定的关于图片的请求参数)
header: {
'content-type': 'multipart/form-data'
}, // 设置请求的 header
success: function (res) {
console.log(res.data);
},
fail:function(error){
console.log("error")
}
})
}

猜你喜欢

转载自www.cnblogs.com/riyueqian/p/12557644.html