2

I have file upload control in page through which user uploads files to application. I need to restrict user to upload exe,msi and batch files. I checked file extensions it is working fine but when i change an exe file extension to .txt it is allowing me to upload and also i checked with content type of a file. MS excel is not installed on my machine. for an excel file content-type showing as application/octet-stream and for an exe file also content-type showing as application/octet-stream. so that am aunable to upload excel files also. For many of the files am getting content type as application/octet-stream.

Please help me is there any piece of code to find out exe,msi and batch (.bat) files.

user1463065
  • 563
  • 2
  • 11
  • 30
  • 1
    http://stackoverflow.com/questions/58510/using-net-how-can-you-find-the-mime-type-of-a-file-based-on-the-file-signature – CodingDefined Dec 04 '14 at 04:47
  • I don't think you're going to find that this is very easy. I'd allow them to upload whatever they want (or place restriction so that only text files are saved, not binary), just make sure the place that it's uploaded to is restricted so that it can't execute. And of course, appropriate scanning of the files before opening them! – mason Dec 04 '14 at 05:04

0 Answers0