I want to write data to an 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 questions but everywhere they are printing it on console.
At some place they have given code but it is not working.
So please can any one help me: How to actually write data to file?
I referred the code but its not working. It is giving the following 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?