Skip to main content
Participant
December 4, 2008
Answered

Help with CFIMAGE

  • December 4, 2008
  • 2 replies
  • 495 views
I'm trying to resize a file using the CFIMAGE tag for a file a user has selected from his local workstation, which I've put into a variable. The value of this variable always comes up as a temporary file name with a .tmp extention. The CFIMAGE fails every time because it is not recognizing the image file due to the .tmp . Any suggestions anyone????

Thanks!
This topic has been closed for replies.
Correct answer -__cfSearching__-
> The value of this variable always comes up as a temporary file name with a .tmp extention.

Uploaded files are sent to a temporary directory and assigned a .tmp file extension. You must use cffile action="upload" to finish the upload (for lack of a better description). The file is already saved on the server, the call to cffile just moves it to a different directory and restores the correct file extension.

> The CFIMAGE fails every time because it is not recognizing the image file due to the .tmp .
> Any suggestions anyone????

1. Use cffile action=upload first
2. Use the ImageNew() function to read in the file

2 replies

VaQueenBAuthor
Participant
December 5, 2008
Awesome! Worked great -- thanks for the help!!
-__cfSearching__-Correct answer
Inspiring
December 4, 2008
> The value of this variable always comes up as a temporary file name with a .tmp extention.

Uploaded files are sent to a temporary directory and assigned a .tmp file extension. You must use cffile action="upload" to finish the upload (for lack of a better description). The file is already saved on the server, the call to cffile just moves it to a different directory and restores the correct file extension.

> The CFIMAGE fails every time because it is not recognizing the image file due to the .tmp .
> Any suggestions anyone????

1. Use cffile action=upload first
2. Use the ImageNew() function to read in the file
VaQueenBAuthor
Participant
December 5, 2008
Great, thanks. I was able to get the file uploaded fine, but am now having issues with the ImageNew(). I'm getting this error:
The ImageNew(uploadedFile,350,263) image format is not supported on this operating system.

My code is below. I want the image sized at 350x263.
Thanks for your help!
Inspiring
December 5, 2008
VaQueenB wrote:
> I was able to get the file uploaded fine, but am now having issues with the ImageNew(). I'm getting this error:

Sorry, my response was unclear. I meant either use option 1 _or_ option 2. For whatever reason, ImageNew understands it is an image file, even though it has a .tmp file extension (unlike cfimage).

But since you are using option 1, just replace the "ImageNew(uploadedFile,350,263)" portion with the full path to your image file (ie c:\myimages\someImage.jpg). Your "result" variable will contain the file details, like the serverDirectory and file name. Use those values to construct the path to the file. Check the documentation to see all of the available file details:
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_f_10.html


Something like this should read in the image. It is not tested. So watch out for typos and verify it actually _does_ produce a valid file path ;-)

<cfset pathToImage = uploadedFile.serverDirectory &"\"& uploadedFile.serverFile>
<cfoutput>
debug pathToImage = #pathToImage#<br>
does the file exist? #FileExists(pathToImage)#
</cfoutput>

<cfimage action="read"
source="#pathToImage#"
name="readFile"
>