Skip to main content
Participant
May 2, 2023
Question

CFFILE Move Works, but Rename Fails

  • May 2, 2023
  • 1 reply
  • 288 views

I'm migrating files from Windows ColdFusion 2018 to Linux ColdFusion 2018. On the Windows Server, I can successfully run the following code:

<cffile action="rename" source="#srcDIR#" destination="#destDir#\#form.memID#.PNG" nameconflict="overwrite">

 

Where #srcDIR# is the path to the image that needs to be moved. But on Linux, the same command below fails "The source ... specified in the cffile tag is invalid." I added a CFIF FileExists check and it's returns as true, so #srcDIR# can be found.

<cffile action="rename" source="#srcDIR#" destination="#destDir#/#form.memID#.PNG" nameconflict="overwrite">

 

If I change the cffile to move and remove nameconflict as shown next, it works:

<cffile action="move" source="#srcDIR#" destination="#destDir#/#form.memID#.PNG">

 

Anybody have a clue why rename fails, but move works?

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    May 3, 2023

    Does rename work after you remove the nameConflict attribute? If what I am thinking is correct, then that will produce the same error.

     

    What I am thinking is as follows: the rename is actually equivalent to moving the file #srcDIR# to the new location #destDir#/#form.memID#.PNG.

     

    After that, the file #srcDIR# no longer exists. Hence the error. Unless in the case when the paths #srcDIR# and #destDir#/#form.memID#.PNG are the same.

     

     

    mpinetsAuthor
    Participant
    May 15, 2023

    Hey BDBK

     

    No, it didn't work when I removed the nameConflict attribute. I ended up sticking with move and continue working. Just thought it was strange that rename worked on Windows server, but not on a Linux server.

    BKBK
    Community Expert
    Community Expert
    May 15, 2023

    Thanks for the update.

    If it works on Windows but not on Linux, then that might be a bug. I would suggest you report it