JPG files which won't write
Apr 28
Here was a problem that occurred for me the other day that you all may have encountered. When I was attempting to upload certain image files, Coldfusion would throw an error!
"An exception occurred while trying to write the image. Ensure that the destination directory exists and that Coldfusion has permission to write to the given path or file. cause : coldfusion.image.ImageWriter$ImageWritingException: An exception occurred while trying to write the image."
This pesky problem wouldn't seem to go away, even if the application did indeed have write permissions! It turns out there is a bug in coldfusion related to this. The first thing I did related to this was install the Coldfusion image hotfix:
http://kb.adobe.com/selfservice/viewContent.do?externalId=kb403411&sliceId=1
This however didn't fix the problem entirely. If this doesn't work for you when uploading certain JPG images, try this:
2<cfset image_file = imageNew(strFile)>
3<cfimage action="write" destination="#this_image_path#\#file.ServerFile#" source="#image_file#" overwrite="yes">
What this piece of code does is reads in the image file using the readbinary file functionality instead of using CFImage's file tools. Immediately after, it reads the data as an image then writes it to the server. The added benefit is that photo's added this way can also be properly manipulated by cfimage and the equivalent cfscript versions of those functions.
Team Ravenglass