Reputation: 63
I want to modify a .txt (overwrite completely) using javascript/jquery. I am currently using the code written below and it is working fine in IE.
var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.OpenTextFile(dir + "modules.txt", 2, true, -2);
s.WriteLine(tobewritten);
s.Close();
fso = s = null;
How can the same be done in Mozilla firefox.
Please note that I am running my application locally and not hosted on a webserver.
Upvotes: 0
Views: 5224
Reputation: 21233
It is possible using HTML5 FileSystem API.
You should be able to achieve following:
More information available here. & here.
Note: This is only supported by modern browsers yet. In fact most of the features are supported in chrome only. Unfortunately firefox doesn't support writing files using FileAPI but they are likely to implement this in future according to this.
Check browser support.
Upvotes: 0
Reputation: 645
It can't. All in-browser JavaScript is sandboxed, so it will never actually allow you to access any local directory.
You can only get around this 'limitation' (I put that in quotes because it's very much purposeful) is to use a browser plugin, like running in-browser Java code or similar, and then use that to access local files.
Upvotes: 4