Phonegap FILE_URI,图片来源

Phonegap FILE_URI, source of image

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);
}

试试这个。

$('#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);
}

如果您在 ipad 上使用 phonegap 桌面应用程序和 phonegap 开发者应用程序,则存在一个已知问题,如果您使用 FILE_URI

https://github.com/phonegap/phonegap-app-developer/issues/174

https://github.com/phonegap/phonegap-app-developer/issues/248