Reputation: 109
I am trying to add data in localstorage when any data is entered in textbox. my question is that how can i add a image in localstorage in Vue js.
Upvotes: 1
Views: 2176
Reputation: 71
You can convert the image to Base64 and store it like a string on local storage;
this link will help you to do that : How can I convert an image into Base64 string using JavaScript?
and when you want to get the image back you will do the opposite process, you need to convert the base64 string to image element, and actually it is very easy, you can put the base64 string as a src of image.
and this a link can help you to do that : convert base64 to image in javascript/jquery
Upvotes: 2