Reputation: 295
I basically want to do this: Allow user to enter the path of an xml file located on their local machine into a textbox.(ie. C:\Requestxml.xml) I then want to load the xml and do stuff with it.
XmlDocument inputXml = new XmlDocument();
inputXml.Load(txtInputXML.Text.Trim());
This works locally, but obviously not when I deploy the site onto the server because it is looking for this path on the server. I would like to know how do I get it to locate the xml file using the path on the user's local machine and not the server?
Solution: This is not possible. Decided to have user paste the xml contents into a textbox and load it that way.
Upvotes: 1
Views: 1057
Reputation: 6839
This is not possible! You have to make the user upload the file to the romote server, then open this after the upload completion. JavaScript from browser has no access to inside user machine.
1) Put a file upload at the page, and then make the user upload it!
2) Implement an event from fileupload control to read the xml and do the logic after the file upload completion.
Upvotes: 1
Reputation: 250972
You should probably use a file input to upload the file to the server, whereby you could do whatever you like with it...
<form name="MyForm"
action="/Uploads/"
enctype="multipart/form-data"
method="post">
<input type="file" name="MyFile"/>
<input type="submit" value="Upload File">
</form>
If you are using Web Forms, there is an equivalent control for this that you can drag onto the page form the toolbar.
Upvotes: 4