user1044209
user1044209

Reputation: 105

How to process uploaded file using Javascript

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?

Upvotes: 3

Views: 6973

Answers (3)

jordancpaul
jordancpaul

Reputation: 2964

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.

Upvotes: 2

Nadh
Nadh

Reputation: 7243

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

Upvotes: 8

Dandy
Dandy

Reputation: 684

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.

Upvotes: -5

Related Questions