Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ok, here is the solution.</p> <ul> <li><p>in the Html file</p></li> <li><p>I have an image tag for displaying the picture taken by the camera :</p></li> <li><p>I have a button that runs a function for taking photo : Capture Photo</p></li> <li><p>The function to capture photo is (when the photo is taken, the scr of the 'smallImage' id is populated with the path of the photo)</p> <pre><code>function capturePhoto() { // Take picture using device camera and retrieve image as base64-encoded string navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50 }); } //Callback function when the picture has been successfully taken function onPhotoDataSuccess(imageData) { // Get image handle var smallImage = document.getElementById('smallImage'); // Unhide image elements smallImage.style.display = 'block'; smallImage.src = imageData; } //Callback function when the picture has not been successfully taken function onFail(message) { alert('Failed to load picture because: ' + message); } </code></pre></li> <li><p>Now I want to move the picture in a permanent folder and then save the link into my database :</p> <pre><code>function movePic(file){ window.resolveLocalFileSystemURI(file, resolveOnSuccess, resOnError); } //Callback function when the file system uri has been resolved function resolveOnSuccess(entry){ var d = new Date(); var n = d.getTime(); //new file name var newFileName = n + ".jpg"; var myFolderApp = "EasyPacking"; window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys) { //The folder is created if doesn't exist fileSys.root.getDirectory( myFolderApp, {create:true, exclusive: false}, function(directory) { entry.moveTo(directory, newFileName, successMove, resOnError); }, resOnError); }, resOnError); } //Callback function when the file has been moved successfully - inserting the complete path function successMove(entry) { //I do my insert with "entry.fullPath" as for the path } function resOnError(error) { alert(error.code); } </code></pre></li> <li><p>My file has been saved in the database to display it, i put "file://" front of the row that contains the image src</p></li> </ul> <p>Hope this help. J.</p> <p>P.S. : - many thanks to Simon Mac Donald (http://hi.im/simonmacdonald) for his post on googledocs.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload