Click here to Skip to main content
15,887,836 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

In my file upload control I can able to upload only txt file extension. Suppose if user change the file type from .exe to .txt and trying to upload I should not allow to upload it. Because of security reason. So .txt should be native. It should not be changed from other format to .txt. How to acheive this in c#?

Please help me.
Posted
Updated 31-May-13 3:42am
v2

1 solution

You can't prevent the upload from happening. The user will be able to upload anything they want. The identification of an .EXE file comes on the server-side. There is no way to reliably determine if a file is native text, but you can look for the signature of an .EXE file in the first few bytes of the file. They all start with with "MZ".
 
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