Copy link to clipboard
Copied
Hi:
I am working on a file copy and move operation, I realized in cffile action="upload", coldfusion can detect if filename already exist and give some error or overwrite, and also give result attribute for me to know what's going on.
But in cffile action="copy" and action="move", there is no nameConflict attribute and result attribute. So I don't know what's going on while copy or move operation, and the worst thing ever, it didn't even generate an error or something or at least give me result for me to detect what's going on. Does it overwrite? How do I check result?
Thanks.
Copy link to clipboard
Copied
As far as I can tell, the engineers figured if you are doing <cffile action="move"....> or <cffile action="copy"...> you are working within your own file system and would create your own file management logic. To that end they created functionality like fileExists() and <cfdirectory...> that can be used to read the state of a directory before and|or after move or copy operations.
Whereas with <cffile action="upload"....> you are working with files from outside users who may (and probably should) have little idea about your file system.
Copy link to clipboard
Copied
Cpthk0, you're right to worry. I think the default behaviour of <cffile action="copy"> and <cffile action="move"> is to overwrite any file of the same name in the destination directory.
Copy link to clipboard
Copied
Hi,,
try this lgic
check the file exits in that folder
<!--- If already exists file its renmaed --->
<cfif FileExists(fullPath)>
<cfset newfilePart = dateformat(now(),'dd_mmm_yyyy')& timeformat(now(),'hh_mm_ss_L')>
<cfset FileName = listinsertat(FileName,(listlen(FileName,".")),newfilePart,".") >
</cfif>
Copy link to clipboard
Copied
Cpthk0, you're right to worry. I think the default behaviour of <cffile action="copy"> and <cffile action="move"> is to overwrite any file of the same name in the destination directory.
And, I think, that ain't OK.
Copy link to clipboard
Copied
![]()
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more