samedi 21 avril 2018

How do I write file non-server side in JavaScript?

Firstly, I'm sorry if my English is awkward. I'm a newbie programmer and this is my first question, so please point out if I made any mistakes.

I wanted to make an offline webpage that can be opened in PC and Android. The webpage will then be stored in a flash disk / memory card, and then opened in different devices, wherever someone stuck that flash disk to. That being said, I can't rely on anything server-side because not every PC has xampp installed and run.

My idea was to write the code in html and javascript, make the database as a JSON, and then I'll change and write back the JSON file to local storage (as in, inside the html folder).

However, I got to a dead end because of security reasons. Javascript can't write to local disk, so I couldn't overwrite the JSON file even though I can read from it.

Reading a few questions here, I saw some recommending HTML5 storage, but I need the written file because it acted as a DB instead.

Another suggestion was SQLite, but all the tutorials regarding SQLite says it needs to be done server-side as well.

Other answers also suggested using Javascript's session storage, but then it won't be a written file.

I needed to be able to copy the database.json file as a backup.

What should I do so that I'll be able to write the JSON file back with JavaScript, without doing anything server-side? The app is supposed to be fully offline.

Thanks before.




Aucun commentaire:

Enregistrer un commentaire