小編給大家分享一下微信小程序?qū)崿F(xiàn)上傳照片代碼的案例分析,希望大家閱讀完這篇文章后大所收獲,下面讓我們一起去探討吧!
紙上談坑
在我實現(xiàn)了這個功能之前,我講講我是怎么在這個坑里爬上來的:
我實現(xiàn)上傳文件后端的接口的參數(shù)是String類型的
前臺傳的參數(shù):/tupian/20230522/404.html 1. MultipartFile 2.base64
微信上傳文件的開發(fā)文檔
小程序代碼
// 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) } }) } }) }, }) 文件上傳