0

I am making simple HTML5 with jquery, where I have some images. I would like to make that application offline. So I would like to save images to local storage when page first visited and on other visits load it from local storage. I read something about it that can be done with BASE64 but I don´t have idea how. Can you give here some examples?

Allan Kimmer Jensen
  • 4,263
  • 1
  • 30
  • 52
Amsik
  • 688
  • 2
  • 6
  • 26
  • 1
    http://stackoverflow.com/questions/19183180/how-to-upload-an-image-save-it-to-localstorage-and-then-display-it-on-the-next – Satpal Apr 30 '14 at 11:53

1 Answers1

2

Hope this was what you where looking for.. THis coverts the image to base64 type

var canvas = document.createElement("canvas");
canvas.width = 100;
canvas.height = 100;
var can = canvas.getContext("2d");
can.drawImage(img, 0, 0);
var dataURL = canvas.toDataURL("image/png");
return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
Nidhin S G
  • 1,585
  • 14
  • 40