Reading content of a file uploaded by user

5 pts.
Tags:
ASP.NET
C#
Hi everyone, new user here. I've been finding it harder and harder to get answers at EE for certain questions, and am hoping someone here will be able to help me! 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 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(); Can I use this for a proprietary file.extension? 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!

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following