I want to allow my users to select a json file from their file systems and load it into the localstorage of their browser without any request to a server. From here I want to allow the user to do some modification of this JSON via a javascript UI before it is posted off to a REST service later. The main reason I want to persist it in local storage is that they can e back to it at a later date rather than having to select it again and I dont want this JSON saved directly on the server until they are ready.
Is this a scenario that can be achieved purely on the client side with as xmlhttprequest to load the file and localstorage to persist it? Have any of you guys implemented something like this before and if so can you provide some guidance?
Many thanks,
kSeudo.
I want to allow my users to select a json file from their file systems and load it into the localstorage of their browser without any request to a server. From here I want to allow the user to do some modification of this JSON via a javascript UI before it is posted off to a REST service later. The main reason I want to persist it in local storage is that they can e back to it at a later date rather than having to select it again and I dont want this JSON saved directly on the server until they are ready.
Is this a scenario that can be achieved purely on the client side with as xmlhttprequest to load the file and localstorage to persist it? Have any of you guys implemented something like this before and if so can you provide some guidance?
Many thanks,
kSeudo.
Share Improve this question asked Apr 10, 2015 at 10:20 kSeudokSeudo 6197 silver badges23 bronze badges 2- I don't think its possible to store file in local storage because it will make the client less secure. – Kira Commented Apr 10, 2015 at 10:24
- You are playing with a JSON file which is on client's machine and localStorage is also a client's browser's storage, client side alone will do it, you don't need to involve any server. – Zee Commented Apr 10, 2015 at 10:26
1 Answer
Reset to default 4Yes, using the HTML5 files api. User will upload file, you can read it and persist it to localStorage, and make amends before posting it to the server. Have a read of This
Obviously you wouldn't save the actual file, just the parsed JSON object.