Using asp.net and c#, my site allows users to save the innerhtml of a certain div to a file. Now I need the reverse.
Here's what I need: upon clicking a button, the user gets a "open file" dialog, which let him choose a file on his pc. Upon choosing it, the site reads the content of the file, and assigns it as the innerhtml of a div.
several points: 1) can this be done without saving the file to the server? I have no need for the actual file, just the contents of it.
2) I would ideally want the file to have a proprietary file extension, so the user doesnt by mistake upload a wrong file. I've been saving the file using
Expand|Select|Wrap|Line Numbers
- Response.ClearHeaders();
- Response.ClearContent();
- Response.AddHeader("content-type", "text/plain");
- Response.AddHeader("Content-disposition", "attachment; filename=yourname.txt");
- Response.Write(divTest.InnerHtml);
- Response.Flush();
- Response.End();
3) Should I be worried about hacking? I.e. can someone put malicious code in the file which, upon loaded as the innerhtml of the div, will cause me havoc?
TIA!