3

I am creating a simple web page to show some content that is created dynamically on my computer and saved in a text file. In looking around, the only way I see to read content from a text file using javascript is to use something that prompts the user for a file read on their system. Something like:

<input type="file" id="fileinput" />

Is there anyway around this? Is there anyway that I can pass a filename in and read the contents?

1
  • is it possible for you to use any server side code, like php or asp? Commented Apr 17, 2016 at 2:17

1 Answer 1

4

No, it is not possible to read a file from the browser without user interaction. That would be a serious security issue. Imagine that any website could read whatever they wanted on your computer. That opens a huge door for abuse.

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

3 Comments

Well, if the user is prompted and he chooses himself that file, then it is possible.
@Cristy OP asked whether a means of reading a file without user interaction exists.
Thanks. I will just use the prompt for file.

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.