Can we insert an image that reads as url in sqlite using javascript?

Hi, I am developing a cross-platform application using cordova. I am trying to insert an image in sqlite. I am reading an image using reader.readAsUrl. This returns some data similar to this in base64 data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAA......, I used firebase to load the image using this following code. It really works so well.
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 to do the same with Sqlite, I cannot insert this image. Can I use this data to insert into the database. Can anybody help me? Thanks in advance.

+4
source share
1 answer

- CDN. .

blob . , .

0

Source: https://habr.com/ru/post/1618874/


All Articles