Reputation: 283
Hey everyone I know that its a controversial topic about storing either the image or the path to the image in the database however for this particular application when the user takes the picture I do not want them to be able to access it and with the way I transmit data to the server I need to send the blob.
Does anyone have a function that will take a picture and save it straight into a column in the sqlite database as a blob?
Thanks, Currently I only have the following functions to handle images:
var pictureSource;
var destinationType;
function onPhotoDataSuccess(imageData) {
console.log("* * * onPhotoDataSuccess");
var cameraImage = document.getElementById('cameraImage');
cameraImage.style.visibility = 'visible';
cameraImage.src = "data:image/jpeg;base64," + imageData;
}
function take_pic() {
navigator.camera.getPicture(onPhotoDataSuccess, function(ex) {
alert("Camera Error!");
}, { quality : 30, destinationType: Camera.DestinationType.DATA_URL });
}
Thanks again everyone!
Upvotes: 0
Views: 4831
Reputation: 2014
I found this: Phonegap Database problem - storing images in the database
there is an answer to it so that should do the trick for you.
a raw example:
function onPhotoDataSuccess(imageData) {
// Get image handle
var smallImage = document.getElementById('smallImage');
// Unhide image elements
smallImage.style.display = 'block';
smallImage.src = imageData;
/* do something else with imageData :) */
}
Read this too please:
http://docs.phonegap.com/en/1.0.0/phonegap_camera_camera.md.html
This is a part of it, but please read before that too ;)
You can do whatever you want with the encoded image or URI, for example:
Render the image in an tag (see example below) Save the data locally (LocalStorage, Lawnchair, etc) Post the data to a remote server
Upvotes: 1