wx.chooseImage({ count: 1, // 默认9 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 sourceType: ['camera'], // 可以指定来源是相册还是相机,默认二者都有 defaultCameraMode: "batch", isSaveToAlbum: 0, success: function (res) { var localIds = res.tempFilePaths[0]; // 返回选定照片的本地ID列表, wx.getLocalImgData({ localId: localIds[0], success: function (res) { var localData = res.localData; if (localData.indexOf('data:image') != 0) { //判断是否有这样的头部 localData = 'data:image/jpeg;base64,' + localData } localData = localData.replace(/\r|\n/g, '').replace('data:image/jgp', 'data:image/jpeg') images.push(localData)//images是业务中用到的变量 showImage(localData) } }); that.setData({ src: localData }) wx.uploadFile({ url: url + 'Upload/PostSaveImg', filePath: that.data.src, name: "门头", header: { "Content-Type": "multipart/form-data" }, method: "POST", formData: { "user": "test", }, success: function (res) { console.log('待用接口') var datas = JSON.parse(res.data); that.data.DataSrc[0] = datas; that.data.SrcTrue[0] = 1; } }) } });
微信小程序手机端无法上传图片?安卓和IOS两个系统上传调用接口不同,但是IOS需要的接口wx.getLocalImgData总显示调用失败,不存在,怎么解决
2021-04-25