微信小程序 上传项目图片

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")
}
})
}
posted @ 2020-03-24 11:03  周千  阅读(256)  评论(0编辑  收藏  举报