Validate file format: not by extension

Hi All,

I want to validate a file format before uploaded on server.

I know it can be validate by content-type or using regex.
But I wonder if someone change the extension of file and then uploaded
it…

I have to validate only two format: 1) wav 2) gsm

Thanks