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?
Asked
Active
Viewed 2,737 times
0
-
1http://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 Answers
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,685
- 2
- 15
- 45