Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jpg content type

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 ?)

like image 307
Oshrib Avatar asked Sep 11 '11 05:09

Oshrib


2 Answers

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.

like image 101
daxelrod Avatar answered Oct 13 '22 23:10

daxelrod


It seems that your code is case sensitive. Try:

if (contentType == "image/jpeg") ..... 
like image 41
Ofer Zelig Avatar answered Oct 13 '22 22:10

Ofer Zelig