Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save File From Local Data in Javascript

Tags:

javascript

Heres the scenario:

  1. User comes to my website and opens a webpage with some javascript functionality.
  2. User edits the data through javascript
  3. User clicks on a save button to save the data, thing is, it seems like they shouldn't need to download this data because its already in javascript on the local machine.

Is it possible to save data from javascript (executing from a foreign webpage) without downloading a file from the server?

Any help would be much appreciated!

like image 971
Travis Avatar asked May 04 '10 01:05

Travis


People also ask

Can you save a file in localStorage?

localStorage can only store Strings, while modern Javascript can also handle binary files. For example, the result of a fetch can be retrieved as a Blob .

Can JavaScript access local files?

Web browsers (and JavaScript) can only access local files with user permission. To standardize the file access from the browser, the W3C published the HTML5 File API in 2014. It defines how to access and upload local files with file objects in web applications.

What does save () do in JavaScript?

What does save () do in JavaScript? save() method of the Canvas 2D API saves the entire state of the canvas by pushing the current state onto a stack.


1 Answers

For saving data on the client-side, without any server interaction, the best I've seen is Downloadify, is a small JavaScript + Flash library allows you to generate and save files on the fly, directly in the browser...

Check this demo.

like image 103
Christian C. Salvadó Avatar answered Oct 30 '22 09:10

Christian C. Salvadó