小程序上传base64的图片,可上传多张


微信小程序上传图片转化为base64格式

clickimage: function(e) {
var index = e.currentTarget.dataset.index;
var count = 4;
var that = this;
wx.chooseImage({
count: count,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success(res) {
var tempFilePaths = res.tempFilePaths;
for (var x = 0; x < res.tempFilePaths.length; x++) {
wx.getFileSystemManager().readFile({
filePath: res.tempFilePaths[x], //选择图片返回的相对路径
encoding: "base64",//这个是很重要的
success: res => { //成功的回调
//返回base64格式
console.log('data:image/png;base64,' + res.data)
}
})
}
}
})
},


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM