• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Help with CFIMAGE

New Here ,
Dec 04, 2008 Dec 04, 2008

Copy link to clipboard

Copied

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!
TOPICS
Advanced techniques

Views

406

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Dec 04, 2008 Dec 04, 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...

Votes

Translate

Translate
Valorous Hero ,
Dec 04, 2008 Dec 04, 2008

Copy link to clipboard

Copied

> 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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 05, 2008 Dec 05, 2008

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 05, 2008 Dec 05, 2008

Copy link to clipboard

Copied

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"
>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 05, 2008 Dec 05, 2008

Copy link to clipboard

Copied

LATEST
Awesome! Worked great -- thanks for the help!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation