Jpg content type

36,672

Solution 1

Caveat: I know almost zero C#.

I suspect this is a casing issue. Try this:

if (contentType.ToLower() == "image/jpeg")

RFC1341 indicates that

The type, subtype, and parameter names are not case sensitive. For example, TEXT, Text, and TeXt are all equivalent.

This means that if contentType is coming verbatim from a user-agent, it could have any capitalization, or none at all.

Solution 2

It seems that your code is case sensitive. Try:

if (contentType == "image/jpeg") ..... 
Share:
36,672
Oshrib
Author by

Oshrib

Updated on July 05, 2022

Comments

  • Oshrib
    Oshrib almost 2 years

    I have the next content-types:

    image/gif

    image/png

    application/vnd.ms

    They all work and recognized the files (gif, png, xls)...

    But what is the content-type for jpg? i know that its the type for jpeg:

    image/pjpeg , image/jpeg

    But it's not work for jpg.

    (I use that with the code:

    if (contentType == "image/JPEG") ..... 
    if (contentType == "image/gif")...
    

    For category the files by their extension. maybe there is other way to do that? not by content- type ?)