Skip to main content
Inspiring
December 5, 2008
Answered

Another CFIMAGE Bug?

  • December 5, 2008
  • 3 replies
  • 2372 views
I'm creating a catalog and I want the user to upload the items which includes a photo. I then store the photo and the other pieces of information in a database. I'm using the cfifle to upload the photo then use cfimage to get the photo info for the insert, I insert the record then I delete the photo from the folder I uploaded it to. Everything worked great. I then changed the destination on the cffile tag to a different location, since the first time I just wanted to see if it would work. The cfimage tag will bomb because it is looking for the photo in the old location and not the new one. The upload went fine to the new location. I cleared the cache, opened a new browser. Why would it still be looking for it in the old location. I change the cffile upload back to the first destination area and it works. Why can't I change the location of where to get the photo? Is cfimage not getting something cleared out?

thanks
    This topic has been closed for replies.
    Correct answer JR__Bob__Dobbs-qSBHQ2
    You might try providing the full path and file name to cfimage.

    <cfset itemPhoto="#cffile.serverdirectory#\#cffile.serverfile#">

    3 replies

    Inspiring
    December 5, 2008
    > I then changed the destination on the cffile tag to a different location
    > ...
    > <cfset itemPhoto = file.ServerFile>
    > <cfimage action="read" source="#itemPhoto#" name="ItemAdded">

    Yes, but where is your upload page located?

    Since you are not passing cfimage an absolute path, it will look in the current directory. If your images are now in a _different_ directory, CF will not be able to find them unless you tell it where to look.

    For example, if your upload page is in the recognition directory:
    c:\Inetpub\wwwroot\safety\recognition\yourUploadPage.cfm

    Cfimage will look in that directory because that is what you are telling it to do here:
    <cfimage action="read" source="#itemPhoto#" name="ItemAdded">

    If CF needs to look in a different directory, either use the correct relative path or an absolute path as JR "Bob" Dobbs suggested.
    BJ_-_CFAuthor
    Inspiring
    December 5, 2008
    Here is the code of the upload and cfimage. The destination I want it to be is this "\inetpub\wwwroot\safety\recognition\photoArea. I'm on CF 8.1.


    <cffile action="UPLOAD"
    filefield="photo_name"
    destination="\Inetpub\wwwroot\safety\recognition"
    nameconflict="MAKEUNIQUE">
    <cfif fileWasSaved EQ 'Yes'>
    <cfelse>
    <script language="JavaScript">
    alert("Photo couldn't be uploaded to the server - Try again or contact the IT Dept.");
    history.back();
    </script>
    <cfabort>
    </cfif>
    <cfset itemPhoto = file.ServerFile>
    <cfimage action="read" source="#itemPhoto#" name="ItemAdded">
    JR__Bob__Dobbs-qSBHQ2Correct answer
    Inspiring
    December 5, 2008
    You might try providing the full path and file name to cfimage.

    <cfset itemPhoto="#cffile.serverdirectory#\#cffile.serverfile#">
    BJ_-_CFAuthor
    Inspiring
    December 5, 2008
    I'll try that but I guess I don't understand. I'm using the same path as before but I want to go down one more level from where I was to write the image.
    Inspiring
    December 5, 2008
    Hi

    Can you provide us the code for reference