My site allows for resume upload, but I want to make sure users won't be uploading anything else but plain text, rtf or word documents (both old *.doc and new *.docx formats). Obviously I can't go entirely by extension, I need to somehow detect file's mime type by its content. Any ideas how to reliably do that for the above types?
Asked
Active
Viewed 2,643 times
2 Answers
1
The browser will send you a mime type when the file is uploaded. While not 100% consistent or reliable, that might be your best bet.

Eric Petroelje
- 59,820
- 9
- 127
- 177
1
This is a duplicate of the Using .NET, how can you find the mime type of a file based on the file signature not the extension question here on stackoverflow. This one includes an answer with a code sample to use the FindMimeFromData method from urlmon.dll.