1

I've developed a survey web app. The app collects data from a survey in a html form, and the user has to upload several photos. The form is posted to a php script that stores the photos on the server and the rest of the form is stored in a MySQL database. Everything is working, but sometimes the surveyors don't have the best internet connection, and we experience a connection loss. Since the survey is time consuming, losing data due to a bad internet connection would be pretty bad. Is there someway to store all the data locally in case of losing the internet connection?

/Carl

react_or_angluar
  • 1,568
  • 2
  • 13
  • 20
carlroger
  • 69
  • 4
  • 9
  • https://www.w3schools.com/html/html5_webstorage.asp Does this answer your question? [How to save JSON data locally (on the machine)?](https://stackoverflow.com/questions/28464449/how-to-save-json-data-locally-on-the-machine) – ikiK Oct 14 '20 at 10:31
  • you could also check if the connection is/gets lost [see here](https://www.google.com/search?q=javascript+check+if+connection+is+lost+site:stackoverflow.com) and prevent submitting the form/save to storage and send later etc – Lawrence Cherone Oct 14 '20 at 10:41

1 Answers1

3

Yes. Lots of apps work that way ( Evernote, Google Keep, etc). You can use localStorage to store simple (serialized data) on the user's computer. Or you can use IndexedDB for storing complex data (images, audio, video, etc..)

When the user is populating the form you should immediately save that data locally on the user system, and when the user submits the data successfully then you delete local data.

Ivan V.
  • 7,593
  • 2
  • 36
  • 53