使用此功能,我可以从手机库获取图像的uri。使用cordova-plugin-camera将URI图像转换为base64格式
function getPhoto() {
navigator.camera.getPicture(onPhotoSuccess, onFail,
{quality: 50,
sourceType: pictureSource.SAVEDPHOTOALBUM,
destinationType: destinationType.FILE_URI,
});
}
function onPhotoSuccess(imageUri) {
var smallImage = document.getElementById('smallImage');
smallImage.style.display = 'block';
smallImage.src = imageUri;
console.log(imageUri);
}
控制台输出正显示出这样的URI: content://com.android.providers.media.documents/document/image%3A76755
是否有可能在imageUri转换为Base64格式,而不是使用<canvas>
? 我正在使用Andriod手机,这是一个cordova应用程序。
图像。它适用于相机。使用data_uri不会解决问题 – vbharath