Edit A Txt File Using Javascript/jquery
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('S
Solution 1:
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.
Solution 2:
It is possible using HTML5 FileSystem API.
You should be able to achieve following:
- Reading and manipulating files: File/Blob, FileList, FileReader
- Creating and writing: Blob(), FileWriter
- Directories and file system access: DirectoryReader, FileEntry/DirectoryEntry, LocalFileSystem
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.
Post a Comment for "Edit A Txt File Using Javascript/jquery"