CFFILE action failure – check the directory path

Encountered an interesting error today after move from CF8 to CF9

the following code produces a path for a directory in which you can use CFFILE actions

<cfset thisPath=ExpandPath("/")>
<cfset thisDirectory=GetDirectoryFromPath(thisPath)>
<cfset RootPath="#thisDirectory#">

However you need to output the rootPath to see if it contains an ending slash or not.
Example we had a data/files/ directory where we wanted to store uploads.

so outputing our RootPath + data/files/ used to give us
Ipaddress//production/CF/application/data/files/

but after the change to CF9 the root path contained its own ending slash so we ended up with
Ipaddress//production/CF/application//data/files/

Notice the extra slash before data. This makes renaming files or moving them impossible. So if your rename or delete isn’t working, try checking your path’s final character.

Cup size   
Select size then click on coffee cup.
This entry was posted in Code. Bookmark the permalink.