uniapp 拍照或者选择相册之后图片转为base64

photoEvent(){

uni.chooseImage({
count:1,
sourceType: [‘camera‘,‘album‘],
success: (res) => {
console.log(‘res‘,res)
console.log(‘1111‘,res.tempFilePaths[0])
plus.io.resolveLocalFileSystemURL(res.tempFilePaths[0],entry =>{
entry.file(file =>{
var fileReader = new plus.io.FileReader()
fileReader.onload = data =>{
console.log(data.target.result)
let base64 = data.target.result
photoAPI({
"images": base64
}).then(({res}) => {
if(res.data.code == 0){
this.resultList = res.data.data.result
}else{
this.$refs.ydPopup.showEvent({
type: ‘error‘,
message: res.data.msg
});
}
console.log(‘res.data.data.result‘,res.data.data.result)
console.log(‘this.resultList‘,this.resultList)
})
console.log(‘这个就是转换完的base64(带头的):‘+base64)
}
fileReader.onerror = function(error){
console.log(error)
}
fileReader.readAsDataURL(file)
console.log(file)
},function(error){
console.log(error)
})
})
}
})

}

uniapp 拍照或者选择相册之后图片转为base64

上一篇:Flink Application Development DataStream API Operators Overview-- Flink应用程序开发DataStream API操作符概览


下一篇:智能移动终端应用软件(APP)技术要求