How to save image in localstorage and display


#1

I found examples , but I think they are only for jquery, let me know if there is any plugin or library to help save an image, and then show


#2

Image from the gallery or from the camera? Have you got a code to obtain that photo, so we need only to tell you how to save it in localstorage?


#3

From my galery, can you show me how??


#4

I edit my post, check again


#5

If the image is not so big ( kb ) you can base64 encode it and save in local storage.

Example:

this.local = new Storage( LocalStorage );
this.local.set( 'propic', btoa( YOUR_IMAGE_CONTENT ) );

This code is for Ionic2 ( Doc: http://ionicframework.com/docs/v2/api/platform/storage/LocalStorage/ )

If your are using Ionic 1.x, maybe you can check here: https://dbwriteups.wordpress.com/2015/09/19/saving-images-to-app-storage-in-ionic-using-ngcordova/


#6

But this example is for iphone, work for android the same way??


#7

Sure. Instead of platform add ios you have to write platform add android