Is it possible to write data to file using only JavaScript?

I want to Write Data to existing file using JavaScript.
I don’t want to print it on console.
I want to Actually Write data to abc.txt.
I read many answered question but every where they are printing on console.
at some place they have given code but its not working.
So please can any one help me How to actually write data to File.

I referred the code but its not working:
its giving error:

Uncaught TypeError: Illegal constructor

on chrome and

SecurityError: The operation is insecure.

on Mozilla

var f = "sometextfile.txt";

writeTextFile(f, "Spoon")
writeTextFile(f, "Cheese monkey")
writeTextFile(f, "Onion")

function writeTextFile(afilename, output)
{
  var txtFile =new File(afilename);
  txtFile.writeln(output);
  txtFile.close();
}

So can we actually write data to file using only Javascript or NOT?

10 Answers
10

Leave a Comment