Click here to Skip to main content
15,905,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have asp.net application and I want to read data from client machine. the data is located on client machine C:\ but when I put the path it read data from the server path. How to make it read path from client machine?
Posted
Comments
[no name] 6-Dec-13 10:41am    
Tell client to upload the document to server..
thatraja 6-Dec-13 10:54am    
Post this as answer(with some more details)

1 solution

You would need user consent if you want to do this. If you want to process it on the server then you can upload it there and process it and return user whatever you want to return. For client side processing you can use something like file reader like this:

C#
document.getElementById('file').addEventListener('change', readFile, false);

   function readFile (evt) {
       var files = evt.target.files;
       var file = files[0];
       var reader = new FileReader();
       reader.onload = function() {
         console.log(this.result);
       }
       reader.readAsText(file)
    }


but FileReader is only supported in IE 10 and 11 so you may run into issues there and Here is the jsfiddle: http://jsfiddle.net/XRZNX/[^]

Also have a look at this:
http://stackoverflow.com/questions/750032/reading-file-contents-on-the-client-side-in-javascript-in-various-browsers[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900