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

CFFILE Move Works, but Rename Fails

New Here ,
May 02, 2023 May 02, 2023

Copy link to clipboard

Copied

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?

Views

188

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
Community Expert ,
May 03, 2023 May 03, 2023

Copy link to clipboard

Copied

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.

 

 

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 ,
May 15, 2023 May 15, 2023

Copy link to clipboard

Copied

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.

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
Community Expert ,
May 15, 2023 May 15, 2023

Copy link to clipboard

Copied

LATEST

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

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