0

I would need to add data to a text file from javascript. I've found the following code :

var file = showFilePicker(window, "", Components.interfaces.nsIFilePicker.modeSave, "", function(fp) {return fp.file;});
var outputStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance( Components.interfaces.nsIFileOutputStream);
outputStream.init(file, 0x02 | 0x08 | 0x20, 0644, 0);
outputStream.write(someText, someText.length);
outputStream.close();

However it takes a file chosen by the user thanks to a file picker. In my case, I'd like to write to a text file identified by its URL (for example : C://.../text.js)

4

1 回答 1

0

由于安全限制,这在浏览器中可能是不可能的。不过,您可以使用 NodeJS 来做到这一点。

于 2013-11-01T16:27:16.757 回答