This application will help you to detect uploaded file type .It use simple logic to detect it .
we can also use this logic in validation if needed.