Hi I am developing a cross-platform application using cordova. I am trying to insert image within sqlite. I am reading image with reader.readAsUrl, This returns some data like this in base64 data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAA......, I used firebase to upload image using this following code It really works so fine.
function previewFile()
{
var preview = document.querySelector('img');
var file = document.querySelector('input[type=file]').files[0];
var reader = new FileReader();
reader.onloadend = function () {
var image = reader.result;
if(file.type.match('image.*'))
{
preview.src = reader.result;
fullimage =reader.result;
}
else
{
alert("select an image file");
}
}
if (file) {
reader.readAsDataURL(file);
} else {
preview.src = "";
}
}
Html code:
<input type="file" onchange="previewFile()"><br>
<img src="" height="200" alt="Image preview...">
Now when I try the same with Sqlite I am not able to insert this image.Can I use this data to insert into database. Can someone help me? Thanks in advance..
Aucun commentaire:
Enregistrer un commentaire