Phonegap和相机插件出了问题。我正在尝试在我的视图中显示拍摄的照片,但它不起作用。我可以使用DATA_URL,但我需要它与FILE_URI一起工作(因为他们建议!)
这是我的代码,但我想它不在代码中,因为使用DATA_URL它可以工作,但是FILE_URI却没有,尽管我的代码与文档完全相同。
$('#uploadBusinessCard').on('click', function() {
console.log("capture this foto!");
navigator.camera.getPicture(onSuccess, onFail, {
quality: 10,
destinationType: Camera.DestinationType.FILE_URI
});
});
function onSuccess(imageURI) {
console.log("on success!");
var image = document.getElementById('myImageIdee');
image.src = imageURI;
}
function onFail(message) {
alert('Failed because: ' + message);
}
有效的代码几乎相同:
$('#uploadBusinessCard').on('click', function() {
console.log("capture this foto!");
navigator.camera.getPicture(onSuccess, onFail, {
quality: 10,
destinationType: Camera.DestinationType.DATA_URL
});
});
function onSuccess(imageData) {
var image = document.getElementById('myImageIdee');
image.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message) {
alert('Failed because: ' + message);
}
答案 0 :(得分:0)
试试这个。
$('#uploadBusinessCard').on('click', function() {
console.log("capture this foto!");
navigator.camera.getPicture(onSuccess, onFail, {
quality: 10,
destinationType: Camera.DestinationType.FILE_URI,
saveToPhotoAlbum: true
});
});
function onSuccess(imageURI) {
console.log("on success!");
var image = document.getElementById('myImageIdee');
image.style.display = 'block';
image.src = imageURI;
}
function onFail(message) {
alert('Failed because: ' + message);
}
答案 1 :(得分:0)
如果你在ipad上使用phonegap桌面应用程序和phonegap开发者应用程序,那么如果你使用FILE_URI就会出现一个没有显示图像的knonw问题
https://github.com/phonegap/phonegap-app-developer/issues/174
https://github.com/phonegap/phonegap-app-developer/issues/248