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

cffile copy, move ... filename conflict?

New Here ,
Jul 23, 2009 Jul 23, 2009

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.

7.1K
Translate
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
Valorous Hero ,
Jul 23, 2009 Jul 23, 2009

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.

Translate
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 ,
Jul 23, 2009 Jul 23, 2009

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.

Translate
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
Contributor ,
Jul 23, 2009 Jul 23, 2009

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>          

Translate
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 ,
Jul 23, 2009 Jul 23, 2009
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.

Translate
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 ,
Jul 24, 2009 Jul 24, 2009
LATEST

http://xiaoganmijiu.com/ado/tp.gif

Translate
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