4 Replies Latest reply on Dec 5, 2008 11:20 AM by VaQueenB

    Help with CFIMAGE

    VaQueenB
      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!
        • 1. Re: Help with CFIMAGE
          -==cfSearching==- Level 4
          > 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. Re: Help with CFIMAGE
            VaQueenB Level 1
            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!
            • 3. Re: Help with CFIMAGE
              -==cfSearching==- Level 4
              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"
              >


              • 4. Re: Help with CFIMAGE
                VaQueenB Level 1
                Awesome! Worked great -- thanks for the help!!