2012-04-12 93 views
3

我已經在我的iPad 內置的PhoneGap的應用程序與1.6版本的一套ULR到一個XPage Domino服務器上如何從手機圖片獲取圖片到遠程XPage?

現在我的問題:

當我拍張照片在iPhone和上傳它使用功能takePicture的「返回值」我的XPage 是這樣

data:image/jpeg;base64,file://localhost/var/mobile/Applications/C1ABCAD3-5F54-45AB-81B0-A242940B58CB/tmp/photo_001.jpg 

一個String有沒有機會得到上傳的文件,而不是字符串?

這裏是我使用的代碼:

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

你想要做的就是要求getPicture方法通過指定destinationType爲options的一部分返回FILE_URI代替DATA_URL的。一旦你有了URI,你可以使用FileTransfer.upload來上傳你的文件。

+0

啊謝謝,但是我通過destinationType:Camera.DestinationType.DATA_URL得到了答案,它應該返回一個Base64編碼的圖像而不是FilePath。 – 2012-04-13 08:09:10

+0

我想你遇到了1.6.0中的bug,應該在1.6.1中修復。你在iOS上對嗎? – 2012-04-16 19:13:32

+0

參數確定我使用的1.6不是1.6.1。在iOS上是即時通訊 – 2012-04-17 13:04:06