I have created a Worklight application and added to it the Android environment. This application has a button to take a photo using the device camera, and an img
tag in the HTML which displays the captured photo.
I followed this PhoneGap Camera API.
Now I am trying to store that image into the SD Card but fail doing so. my
EDIT: I changed my code as below:
function takeimage() {
// Retrieve image file location from specified source
navigator.camera.getPicture(getImageURI, function(message) {
alert('Image Capture Failed');
}, {
quality : 40,
destinationType : Camera.DestinationType.FILE_URI
});
}
function getImageURI(imageURI) {
var gotFileEntry = function(fileEntry) {
var img=document.getElementById("thisImage");
img.style.visiblity="visible";
img.style.display="block";
img.src=imageURI;
alert("got image file entry: " + fileEntry.fullPath);
var gotFileSystem = function(fileSystem){
// copy the file
fileEntry.moveTo(fileSystem.root, "pic.jpg", null, null);
};
// get file system to copy or move image file to
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFileSystem, fsFail);
};
//resolve file system for image
window.resolveLocalFileSystemURI(imageURI, gotFileEntry, fsFail);
}
//file system fail
function fsFail(error) {
alert("failed with error code: " + error.code);
}
Everything working fine(capturing image and image available in app cache folder) except moveTo
method.
fileEntry.moveTo(fileSystem.root, "pic.jpg", null, null);
I put fileSystem.root
in alert and I am getting Object object
. So the folder location is not available to move that image(And I think its the real problem).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…