Vineet
Vineet

Reputation: 4645

Store bulk images in $localStorage - Angular JS

I'm using $localStorage service to store data in browser's cache. Actually I'm building a web application ( in angularjs and PHP ) on which user can upload multiple images on canvas, manipulate with them. What I was doing, when user uploads image/s, I was uploading this image to server and when user removes, I am unlinking it from the server but this approach only increases my server space with MBs/GBs of garbage data.

I'm looking to change my approach. Can I upload bulk of images on localStorage and when user submits his/her campaign, only then all of the images will send to the server ? Is there any approach can I go with ?

Upvotes: 0

Views: 272

Answers (1)

Tomek Sułkowski
Tomek Sułkowski

Reputation: 7201

You can do it, and you can read about the sole technicalities of how to achieve that in the answer to this question: How to save an image to localStorage and display it on the next page? (basically it boils down to saving a Base64-encoded image as a string)

Mind that most browsers can only store up to several MB of data (depending on each browser, e.g. 5 for Chrome) in localStorage, so you will be limited by that.

Upvotes: 1

Related Questions