My web form allows users to upload files. If the file is an image, I like to show a thumbnail of the image.
The form allows word docs and pdfs to be uploaded too. For these, I dont display an image.
So, what is the best way to detect a file is an image and to display it in an <img /> control?
Currently I base it on extension. if (ext == ".gif" || ext == "png || img == jpg) img.ImageUrl = file.Name
That list could go on, including tif, bmp. So is there a smarter way?