0

I'm looking to write a small amount of text (or append to the text already stored) in a .txt file on the server's HDD using JavaScript. My intention is for long-term data storage, so temporary files are out of the question. Basically, if I have a file

This is a piece of
and so is

I want to append "text" to line1 and "this" to line2, so as to produce

This is a piece of text
and so is this

I just want to use the most simple method possible. To read the file I am using an XMLHttpRequest object, so perhaps a method using that would be best (but by all means not necessary).

Thanks!

  • 1
    Has already been asked: writing to files: http://stackoverflow.com/questions/2496710/writing-files-in-node-js. And appending to files http://stackoverflow.com/questions/3459476/how-to-append-to-a-file-in-node – dingalapadum Apr 12 '15 at 22:36
  • The answer will be nothing to do with JavaScript unfortunately (unless your server is Node.js). Judging by your HTML tag and the XMLHttpREquest, I'm guessing this is a browser based application. What server side language are you using? You'll need to send the content back in another XMLHttpRequest and save it on your server using your server-side language. – James Hay Apr 12 '15 at 22:42
  • @JamesHay Okay - I got a good Node.js hello world going, but how can I run that from an HTML or JavaScript file? As of now, I'm running it through a .bat file. I'd like the Node.js script to execute via JavaScript function. – FireBreath15 Apr 13 '15 at 03:28

0 Answers0