ColdFusion 无法识别 TIFF MIME 类型?
Coldfusion 8、Apache、Mac OS X 服务器 10.5。
我有一个允许用户上传图像的网络应用程序。但是,总是无法上传 TIFF 文件。 JPEG、GIF 和 PNG 上传没问题,这个问题似乎只存在于 TIFF 中。
用户通过表单中的 cfinput 标签选择要上传的图像。提交表单后,我尝试使用 cfimage 标签重命名并移动文件。对于 JPEG、PNG 等,这可以正常工作,但如果图像是 TIFF,则会出错:
“ColdFusion 无法从指定的源文件创建图像。请确保该文件是有效的图像文件."
接下来,我将 cfimage 标签更改为 cffile 标签,以尝试不同的方式来重命名和移动上传的图像,但这会出现错误:
"上传文件的 MIME 类型服务器不接受 video/x-ms-wm。只能上传 image/* 类型的文件。”
因此,ColdFusion 似乎认为 TIFF 是视频。我双重检查了 /Applications/ColdFusion8/runtime/lib/mime.types,其中包含
image/tiff tiff tif
...就像它应该的那样。为什么 ColdFusion 无法正确获取 TIFF 的 MIME 类型?
非常感谢!
Coldfusion 8, Apache, Mac OS X Server 10.5.
I have a web application which lets users upload images. However, it always fails to upload TIFF files. JPEG, GIF, and PNG upload just fine, this problem seems to be only with TIFFs.
The user selects the image to upload via a cfinput tag in a form. When the form is submitted, I try to rename and move the file using a cfimage tag. For JPEGs, PNGs, etc. this works perfectly, but if the image is a TIFF, it errors out to:
"ColdFusion was unable to create an image from the specified source file. Ensure that the file is a vaild image file."
Next I changed the cfimage tag to a cffile tag to try a different way to rename and move the uploaded image, but that gives the error:
"The MIME type of the uploaded file video/x-ms-wm was not accepted by the server. Only files of type image/* can be uploaded."
So, it seems that ColdFusion thinks TIFFs are videos. I doubled checked /Applications/ColdFusion8/runtime/lib/mime.types, and that contains
image/tiff tiff tif
...just like it ought to. Why can't ColdFusion get TIFFs' MIME type right?
Thanks so much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
上传文件的 MIME 类型由浏览器提供,这意味着它不可靠。
您没有提供任何代码示例,但我猜测您正在标记中使用 accepts 属性。尝试删除它,看看事情是否按预期工作。
使用accepts属性并不是确定文件是否属于某种类型的可靠方法,因为它是由浏览器提供的,因此不可信。相反,您应该查看扩展名,如果您确实想要安全,请使用检查实用程序检查文件并确保它与扩展名相同。
您可以在 Pete Freitag 的博客上阅读有关他的更多信息。 http://www.petefreitag.com/item/701.cfm
The MIME type of an uploaded file is provided by the browser which means it is not reliable.
You did not provide any code samples, but I am guessing you are using the accepts attribute in your tag. Try removing that and see if things work as expected.
Using the accepts attribute is not a reliable way of determining if a file is of a certain type, since it is provided by the browser it cannot be trusted. Instead, you should be looking at the extension, and if you really want to be secure, using an inspection utility to examine the file and make sure it is what the extension says it is.
You can read more about his on Pete Freitag's blog. http://www.petefreitag.com/item/701.cfm
来自 CF 9 发行说明:
From the CF 9 release notes: