我有下一个内容类型:
image/gif
image/png
application/vnd.ms
他们都工作并识别文件(gif、png、xls)...
但是 jpg 的内容类型是什么?我知道它是 jpeg 的类型:
image/pjpeg , image/jpeg
但它不适用于 jpg。
(我将其与代码一起使用:
if (contentType == "image/JPEG") .....
if (contentType == "image/gif")...
按扩展名对文件进行分类。也许还有其他方法可以做到这一点?不是按内容类型?)
最佳答案
警告:我对 C# 的了解几乎为零。
我怀疑这是一个外壳问题。试试这个:
if (contentType.ToLower() == "image/jpeg")
RFC1341表示
The type, subtype, and parameter names are not case sensitive. For example, TEXT, Text, and TeXt are all equivalent.
这意味着如果 contentType 是从用户代理逐字输入的,它可以有任何大写,或者根本没有。
关于c# - Jpg 内容类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7376553/