Ameen
Ameen

Reputation: 1907

read file and display content in javascript

I need to save some data in a file and when loading the page i want to read this file and add this data to the page. I don't know why but this assignment is useless so we can't use database nor server stuff, so i have to save and read from a local file.

I searched the net and found knew that it is not allowed to access files directly from javascript but using the FileAPI in HTML5 i can select a file to read.

So my question is how is this done because there are no resources about this, i simply need to read a file and into a string. Thanks,

Upvotes: 2

Views: 4172

Answers (1)

Yahia
Yahia

Reputation: 70369

For using the File API (HTML5) including reading/writing the content of local files and some sample source code see these links:

You should be aware that not all borwser/versions support all of the above AND that access to local filesystem depends on security settings...

Upvotes: 3

Related Questions