开发者

Jpg content type

开发者 https://www.devze.com 2023-04-03 20:58 出处:网络
I have the next content-types: image/gif image/png application/vnd.ms They all work and recognized the files (gif, png, xls)...

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 == &开发者_StackOverflow社区quot;image/gif")...

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


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.


It seems that your code is case sensitive. Try:

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

精彩评论

暂无评论...
验证码 换一张
取 消