0

Possible Duplicate:
How to read and write into file using JavaScript

javascript functions for file manipulations like reading & writing ? Im looking for word by word file reading & appending each word in an array of strings.

2
  • 1
    Where is the JS running? Browser? ASP? Node? Where is the text file being accessed from? File system? HTTP? Commented Jun 8, 2011 at 12:10
  • This has been asked many times before. The short answer is that standard in-browser JavaScript doesn't allow this for obvious security reasons. Certain browsers may have certain operations you can use from JavaScript (ActiveX objects, etc.), and server-side JavaScript can probably do this. But JavaScript alone from within a browser, no. Commented Jun 8, 2011 at 12:11

2 Answers 2

0

JavaScript is a client-side language, and as such it runs on the client of the user viewing your site and running your script. You can't access server files directly from JavaScript, and can't access client files at all.

However, HTML5 introduces some storage options if that can fit your needs.

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

Comments

0

On the server. Try using node.js.

In particular read the File System documentation.

As for the Browser: You cannot access the file system through a browser.

Using HTML5 however, there is a File reading API you can use to ask a user to open a file then read it using JavaScript.

The MDC has some information

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.