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.

Community
  • 1
  • 1
Mandar Pande
  • 12,250
  • 16
  • 45
  • 72
  • 1
    Where is the JS running? Browser? ASP? Node? Where is the text file being accessed from? File system? HTTP? – Quentin Jun 08 '11 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. – David Jun 08 '11 at 12:11

2 Answers2

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

Raynos
  • 166,823
  • 56
  • 351
  • 396
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.

Dvir
  • 5,049
  • 1
  • 23
  • 32