Skip to content Skip to sidebar Skip to footer

Save Coordinates In A Text File

I am using HTML and javascript to draw a line and display the coordinates of that line. Here is the Demo on jsfiddle. I want to store these coordinates in a text file instead of di

Solution 1:

At one point the W3C File API included a saveAs method which allows you to save files to a users local file system using javascript.

The saveAs part of the File API has now been removed by browsers for very good security reasons.

Eli Grey has coded a nice plugin that allows you to download files (like your points file) to a users local filesystem. The user must confirm that they want the downloaded file before it's saved to their filesystem. Again, this is for very good security reasons.

The FileSaver plugin: https://github.com/eligrey/FileSaver.js/

You might also check out Juhana's suggestion of using web storage (also known as localstorage) to store your points data to a "sandboxed" storage area. The storage area is located on the users local filesystem, but access is restricted to your web page only--"sandboxed". Localstorage does not require a user to confirm the save.

Post a Comment for "Save Coordinates In A Text File"