【发布时间】:2016-08-24 00:32:17
【问题描述】:
当用户从照片库中选择图像时,我需要获取图像名称和 base64 图像。我正在使用 cordova 相机插件从图库中获取图像,但我没有同时获取图像名称和 base64 图像。
// to get base64 image
Camera.getPicture({
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
targetWidth: 1000,
targetHeight: 1000
}).then((imageData) => {
// imageData is a base64 encoded string
this.base64Image = "data:image/jpeg;base64," + imageData;
alert("this.base64Image="+this.base64Image);
}, (err) => {
console.log(err);
});
//to get image URL
Camera.getPicture({
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
targetWidth: 1000,
targetHeight: 1000
}).then((imagePath) => {
// imageData is a base64 encoded string
this.imagePath = imagePath;
alert("this.imagePath="+this.imagePath);
}, (err) => {
console.log(err);
});
我怎样才能通过单击将这两个调用结合起来?
【问题讨论】:
-
我要给你看cordova代码吗?因为我不熟悉ionic
标签: cordova ionic-framework cordova-plugins ionic2