十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
小编给大家分享一下微信小程序实现上传照片代码的案例分析,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!
纸上谈坑
在我实现了这个功能之前,我讲讲我是怎么在这个坑里爬上来的:
我实现上传文件后端的接口的参数是String类型的
前台传的参数:/tupian/20230522/404.html 1. MultipartFile 2.base64
微信上传文件的开发文档
小程序代码
// index.js Page({ data: { }, uploader: function () { wx.chooseImage({ count: 1, success: function(res) { let imgPath = res.tempFilePaths[0] wx.uploadFile({ url: 'http://localhost:8080/customerRegister/uploadPricture', filePath: imgPath, name: 'files', success:res=>{ console.log(res) } }) } }) }, }) 文件上传