1

I'm aware JS isn't a server side script, but I'm building a mobile app, and I'm going to use the web view controller on android and would like the ability to be able to read a file into an array using JS. Is there anyway of doing this?

Thanks

2
  • 1
    JS is server-side script. nodejs.org Commented Feb 17, 2013 at 19:54
  • Is it a local file (on device) or a file on server. Commented Feb 17, 2013 at 19:54

1 Answer 1

1

You can use the HTML5 FileReader API. With it you can read the file as:

void readAsArrayBuffer(in Blob blob); //Requires Gecko 7.0
void readAsBinaryString(in Blob blob);
void readAsDataURL(in Blob file);
void readAsText(in Blob blob, [optional] in DOMString encoding);

Here are few examples.

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

1 Comment

Thank you! Didn't realise there was such an option with HTML 5.

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.