问题
I've built an Phonegap App with version 1.6 on my iPad an set the ulr to an XPage on the Domino Server
now to my problem:
When I take a picture on the iPhone and upload it to my XPage
using the function takePicture
the "returnvalue" is a String like this
data:image/jpeg;base64,file://localhost/var/mobile/Applications/C1ABCAD3-5F54-45AB-81B0-A242940B58CB/tmp/photo_001.jpg
is there a chance to get the file uploaded and not the string?
here is the code I'm using:
XSP.submitLatency = 300*1000;
function takePicture() {
navigator.camera.getPicture(displayPicture,
showError,
{ quality: 50 }
);
}
function displayPicture(data) {
alert("Hallo" );
var imagePanel = document.getElementById('imagePanel');
imagePanel.style.display = "";
imagePanel.style.position = "absolute";
imagePanel.style.top = "250px";
imagePanel.style.left = "0px";
alert("data:image/jpeg;base64," + data)
document.getElementById('image').src = "data:image/jpeg;base64," + data;
document.getElementById("#{javascript:getClientId('inputHidden1')}").value = "data:image/jpeg;base64," + data;
document.getElementById("#{javascript:getClientId('button1')}").disabled = false;
}
function showError(fail) {
alert(fail);
}
回答1:
What you want to do is to ask the getPicture method to return a FILE_URI instead of the DATA_URL by specifying the destinationType as part of the options. Once you have the URI you can use FileTransfer.upload to upload your file.
来源:https://stackoverflow.com/questions/10126658/how-to-get-a-picture-from-phonegap-to-a-remote-xpage