开发者

ColdFusion Not Recognizing TIFF MIME type?

开发者 https://www.devze.com 2023-04-05 11:25 出处:网络
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,

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!


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


From the CF 9 release notes:

79685 CFIMAGE

On Mac OS X Snow Leopard, cfimage tag does not support TIFF images for read/write operation though getReadableImageFormats and getWriteableImageFormats list TIFF as a supported image format.

0

精彩评论

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

关注公众号