0

Is their a way- client side, to add text to a file named text.txt in javascript?

In python:

f = open("text.txt","w")
f.write("Hello World")
f.close()

would write "Hello World" into the text file. I want to do something similar with javascript.

Note: I am running these files locally.

kirtan-shah
  • 405
  • 7
  • 21
  • This question should help: http://stackoverflow.com/questions/16055391/writing-data-to-a-local-text-file-with-javascript – Papa Dec 16 '14 at 23:52

1 Answers1

0

Its a bit more tricky than in python. The problem is that the browser sandboxes your session and your possibilities. It is possible to request storage space and read and write files in that space.

More info: http://www.html5rocks.com/en/tutorials/file/filesystem/

It would be a security nightmare if a javascipt file could just open files in the root or any other folder. A different approach would be to upload the file in the client/ to the server edit it and send it back in a response.

Brett
  • 99
  • 5