i'm creating a simple file upload mechanism for an asp.net website, and i'm stuck at the validation part, not with the code but with how i should go about checking the files type, considering the uploader needs to only allow certain file types (namely image types) and i feel that validating the extension via regular expression is a bit of a flimsy way of validating the files considering i could upload a pdf with the extension jpg and it wouldn't get flagged.
is using regular expressions the best way of validating a files type?
Edit: asking whether it's best to validate a file type via extension is the best way, not how to do it.