0

I am writing a JavaScript to write file to the local directory in an aframe virtual reality application using Google Chrome.

While debugging I've gotten this error:

Uncaught TypeError: Failed to construct 'File': 2 arguments required, but `only 1 present.`

I've gotten the following code from someone else and I don't understand why Google Chrome says 2 arguments are required for this?

<script>
/// write to file
var txtFile = "skycolour.txt";
var file = new File(txtFile);
var str = "My string of text";

file.open("w"); // open file with write access
file.writeln("First line of text");
file.writeln("Second line of text " + str);
file.write(str);
file.close();
</script>

Thank you for helping out.

Image of the error for your reference

Community
  • 1
  • 1
Jim Ng
  • 91
  • 1
  • 4
  • 15

0 Answers0