3

I am trying to process an XML file using Javascript.

xhttp.open("GET","exportproject.xml",false); 

What I want to do is, let the user specify the file (instead of hard-coding it to exportproject.xml) using file uploader and then process the same using Javascript instead of sending it to the server.

Is it possible?

3 Answers 3

8

You may want to take a look at the HTML5 FileReader API - http://www.html5rocks.com/en/tutorials/file/dndfiles/

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

Comments

2

If you don't mind a solution that requires a modern browser (basically, ie 9+) you can use the html5 file API with a basic <input type="file">.

Take a look at this link, there are a number of excellent examples to get you started.

Comments

-5

Javascript cannot read a file from the client machine (where the browser runs). That would be a security violation. You will have to submit the file to server and process it.

1 Comment

it doesn't make sense to say that you violate less security submitting to the server than processing locally.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.