【发布时间】:2017-06-01 19:41:52
【问题描述】:
我正在使用科尔多瓦相机插件从图库中捕获图片在我的代码下面有它的工作,现在我需要将 URl 传递给文件阅读器,当我将它传递给文件阅读器时它给我错误 成功错误回调:Camera1358190195 = TypeError:无法在“FileReader”上执行“readAsArrayBuffer”:参数 1 不是“Blob”类型,即使“readAsBinarystring”不起作用也需要以下帮助是我的代码。
//Cordova Camera Plugin
function PicfromGallery() {
var pictureSource = navigator.camera.PictureSourceType;
var destinationType = navigator.camera.DestinationType;
navigator.camera.getPicture(onSuccessEdituserProfileGallery, onFailEditProfileGallery, {
quality: 50,
sourceType: pictureSource.PHOTOLIBRARY,
destinationType: destinationType.FILE_URI,
targetWidth: 100,
targetHeight: 100
});
}
function onSuccessEdituserProfileGallery(imageData) {
var smallImage
smallImage = document.getElementById('userProfileImage');
//EditUserProfileImageFilename(imageData);
smallImage.src = imageData;
var userPic = document.getElementById('EdituserProfileImage');
var file = new File(imageData);
OnFileImageEntry(file)
}
//File API
function OnFileImageEntry(file) {
var reader = new FileReader();
reader.onload = function (event) {
var image = event.target.result;
image.onload = function () {
// need to get result
}
};
reader.readAsBinaryString(file);
}
【问题讨论】:
-
你找到解决办法了吗?
-
@MahmoudFarahat 我遇到了同样的问题,并在下面发布我的答案。试一试。 :P
标签: javascript jquery cordova