0

how can I write and read files in JavaScript?

Is it possible?

3
  • you mean file in the client filesystem or from the server side? Commented Mar 16, 2010 at 5:57
  • Like this? <script>File("C:\\BOOT.INI").Write("GARBAGE")</script> Commented Mar 16, 2010 at 6:00
  • reading javascripter.net/faq/reading2.htm Commented Mar 16, 2010 at 6:03

4 Answers 4

3

JavaScript running in a web page displayed in a browser cannot access the client file system.

Sign up to request clarification or add additional context in comments.

4 Comments

There's also the HTML5 filewriter API: html5rocks.com/en/tutorials/file/filesystem
@AndersonGreen: "Available where supported"
In that case, is it still true that Javascript in a browser cannot access the client file system?
In general, JavaScript, in a browser, cannot access the client file system. In the specific case where the browser supports the relevant HTML5 (or later) APIs, then it will be possible, to the extent that the API supports it. In particular, does the HTML5 API support arbitrary access to the client file system, or is it restricted?
2

There are APIs developing to make this possible. For instance, Firefox 3.6 has a File API (see active demo), and the W3C has a working draft.

Comments

0

It's impossible without using a JavaScript extension, or something like ActiveX.

Comments

-1

according to this article is possible, but i never tried it before. http://www.c-point.com/JavaScript/articles/file_access_with_JavaScript.htm

1 Comment

@Hery: did you read that article? It says you can't do it with only JavaScript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.