2

My code takes an uploaded file, resizes it and attempts to save it to another file, from a temp folder to destination folder. I've tried all variations of sample code found online. When the cfimage tag goes to save the resized image, the file disappears from the original location. Then this error is thrown:

d:\temp\imageUploads\HeadshotsampleRDB.jpg (The system cannot find the file specified) 

If I change the destination to the final location, the original file reappears!

<cffile
    accept="image/gif, image/jpeg, image/jpg, image/pjpeg, image/png, image/xpng, image/x-png"
    action="upload"
    nameconflict="makeunique"
    filefield="newphoto"
    destination="d:\temp\imageUploads">

<cfset destFileName = session.Lastname & "_" & CreateUUID() & "." & cffile.serverFileExt>

<cfimage action="info" source="d:\temp\imageUploads\#cffile.serverfile#" structname="info">

<cfif info.width GT 100 OR info.height GT 150>
    <cfif info.width GT 100>
        <cfset lawyerImage=ImageNew("d:\temp\imageUploads\#cffile.serverfile#")>
        <cfset ImageResize(lawyerImage,"100","","highestPerformance",1)>
        <cfimage action="write" source="#lawyerImage#" destination="d:\temp\imageUploads\#cffile.serverfile#" overwrite="yes">

    <cfelse>
        <cfset lawyerImage=ImageNew("d:\temp\imageUploads\#cffile.serverfile#")>
        <cfset ImageResize(lawyerImage,"","150","highestPerformance",1)>
        <cfimage action="write" source="#lawyerImage#" destination="d:\temp\imageUploads\#cffile.serverfile#" overwrite="yes">
    </cfif>
</cfif>

<cffile action="rename"
    source="d:\temp\imageUploads\#cffile.serverfile#"
    destination="#imgsPath#\photos\#destFileName#">

I could swear I have hot fix 4 installed, I see the file, but the CF Admin only shows us at hot fix level 2.

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Connie DeCinko
  • 996
  • 5
  • 19
  • 39
  • Confirmed, we do have the cumulative hot fix 4 installed, just upgraded to the level 7 security hot fixes. – Connie DeCinko Jun 15 '17 at 01:00
  • 2
    What is the full trace? FileNotFoundException does not always mean the file does not exist. It is a general exception that can indicate any number of issues. Such as that the file exists but a) is locked or inaccessible or b) the account may have insufficient permissions. Check the actual physical directory to see if the file exists. Also, check the permissions on the temp folder versus the "destination" folder. – Leigh Jun 15 '17 at 02:46
  • 1
    Adding to Leigh's list: c) there's no more free space available on the disk. (Yes, we actually had this issue once.) – Alex Jun 15 '17 at 10:50
  • Have you tried wrapping the code in a try/catch and `` ? – James A Mohler Jun 24 '17 at 20:17

0 Answers0