Is there any way to create a file(.txt) in javascript? Can we access the filesystem through javascript. and write the files?
-
1JS is client side. Files are server side.tckmn– tckmn2013-03-04 13:27:57 +00:00Commented Mar 4, 2013 at 13:27
-
1In short: no. Think about what the security implications were if you could.deceze– deceze ♦2013-03-04 13:28:41 +00:00Commented Mar 4, 2013 at 13:28
-
2See stackoverflow.com/questions/7545736/…Grim– Grim2013-03-04 13:28:41 +00:00Commented Mar 4, 2013 at 13:28
-
2What are you trying to achieve? Where are you trying to achieve it? JavaScript is not strictly client-side (node.js), so it really depends on those factors. Without more information, we cannot help.itdoesntwork– itdoesntwork2013-03-04 13:29:09 +00:00Commented Mar 4, 2013 at 13:29
-
3@itdoesntwork You'd think if the OP was writing in node.js he wouldn't ask this question... :)deceze– deceze ♦2013-03-04 13:30:10 +00:00Commented Mar 4, 2013 at 13:30
|
Show 1 more comment
2 Answers
There are experimental HTML5 FileSystem APIs but they are not yet widely supported.
They have some limitations:
If you're calling
requestFileSystem()for the first time, new storage is created for your app. It's important to remember that this file system is sandboxed, meaning one web app cannot access another app's files. This also means you cannot read/write files to an arbitrary folder on the user's hard drive (for example My Pictures, My Documents, etc.).
Comments
Yes, somehow reading file is easy with Javascript FileReader. You can see documentation
4 Comments
deceze
This does not allow you to create arbitrary files though.
Talha Akbar
@deceze have seen the line i have written before giving link of documentation ? I know it can't write files.
deceze
Sure, just pointing out that it doesn't answer the question.
Talha Akbar
@deceze maybe, help a future user. But i think in future HTML gonna be more powerful. We can keep it on desk or you want to say that i need to delete it ?