I am uploading an image and naming it in the destination attribute using a Session value & some fixed text, but I dont know how to preserve the file name extension so that I can edit the image using CfImage.
My action code looks like this, and it works.
CODE
cffile action="upload" destination="#ExpandPath('/images/homes' & '#SESSION.mm_listing_id#' & '_image1' & '.jpg')#" filefield="FORM.upload_file" nameconflict="overwrite" accept="image/*"/>
The problem comes when I try to resize the image. While the file uploads and renames the way I want, since I have defined the extension as .jpg, Coldfusion throws an error when the original image is not a jpg.
Here is the cfimage code that fails when I apply it to an image with an improper extension.
CODE
<cfimage action="resize" width="300" height="" source="#ExpandPath('/images/homes/#file.ServerFile#')#" destination="#ExpandPath('/images/homes')#" overwrite="yes">
The question is, can I name the uploading file in the destination attribute and maintain the files original extension so that I can later edit the file with CfImage?