title: .NET C# image upload validation
body: <p>i'm currently developing a website where the user is able to upload a valid image and not any other file types for security purposes. Atm i have this code but the image extension could still be tampered.</p>
  
  <pre><code>if (extension == ".jpg" || extension == ".jpeg" || extension == ".JPG" || extension == ".gif" || extension == ".png"
  </code></pre>
  
  <p>Is there any way to make absolutely sure that only these image formats are allowed and that they cannot be altered (like a global code for each format). Thanks</p>