2

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,

1
  • By assignment, do you mean this is for a class? If it is, please add a homework label. Commented Nov 5, 2011 at 18:47

1 Answer 1

3

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...

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

7 Comments

The html5rocks links is particularly helpful.
Great links buddy, but i'm having a problem with initializing this file and it is giving me security error, any idea how to resolve this?
@Ameen as I wrote any access to filesystem is prone to security settings... these you can't resolve in code - it is a setting in the client (browser)!
ok any idea how to do this in google chrome because i tried to deactivate anything i consider security and still getting the same error.
@Ameen sorry, no idea - I don't use Chrome :-(
|

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.