jeudi 7 avril 2016

Storing captured image into SQlite Database? (Cordova)

So far I have got the camera api working for my app, to which the camera is opened when a button is clicked and once the image is taken it is displayed on the page.

My next step is to store the image into my sqlite database within a table. Create the database is no problem as I already have a couple of other tables used for other parts of the app, it's just finding out how to store the image into the database.

Can someone provide some assistance here?

Camera Function:

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
  document.getElementById("btnCamera").onclick = function() {
     navigator.camera.getPicture(function (imageUri) {
     var lastPhotoContainer = document.getElementById("lastPhoto");
     alert("Hot stuff!");
     lastPhotoContainer.innerHTML = "<img src='" + imageUri + "' style='width: 75%;' />";
     }, null, null);
          };
          }

HTML:

<div data-role="page" id="page7" data-theme="d">
    <div data-role="header">
        <a href="#page1" class="ui-btn ui-icon-home ui-btn-icon-left">Sign ut</a>
        <h1>SoccerMeet</h1>
    </div>
    <div data-role="main" class="ui-content">
        <input id="btnCamera" type="button" value="Camera photo" />
        <p id="lastPhoto"></p>
    </div>

    <div data-role="footer">
        <h2>&copy; Gallery</h2>
    </div>
</div>

Aucun commentaire:

Enregistrer un commentaire