Solved

Problem with using CFFile to move files

Posted on 2006-07-18
5
694 Views
Last Modified: 2013-12-24
Hi there - I am having some problems using CFFile to move files from one directory to another. It seems to only move some of the files in the group that I choose to move over, and there is nothing specific about which files are moved - different files are moved each time. There are no error messages that are showing up, so I am totally baffled. I have verified that the files exist in the original location beofre they are moved - so I dont know what the cause could be.  Has anyone else experienced this and does anyone else have any ideas on how to fix this problem? Any help would be much appreciated!! My code is below.

<cfset newDir = "#globals.dp_image_dir##icid#">
<cftry>
      <cfdirectory action="create" directory="#newDir#">
      <cfcatch type="any"></cfcatch>
</cftry>

<cftry>
      <cffile
            action="move"
            source="#globals.dir#clients\#icid#\resources\#FORM.templateAppNewInstallImage#"
            destination="#newDir#\">
      <cfcatch type="any"></cfcatch>
</cftry>

<cftry>
      <cffile
            action="move"
            source="#globals.dir#clients\#icid#\resources\#FORM.templateAppPreferencesHeaderImage#"
            destination="#newDir#\">
      <cfcatch type="any"></cfcatch>
</cftry>

<cftry>
      <cffile
            action="move"
            source="#globals.dir#clients\#icid#\resources\#FORM.templateAppIconConnected#"
            destination="#newDir#\">
      <cfcatch type="any"></cfcatch>
</cftry>

<cftry>
      <cffile
            action="move"
            source="#globals.dir#clients\#icid#\resources\#FORM.templateAppIconDisconnected#"
            destination="#newDir#\">
      <cfcatch type="any"></cfcatch>
</cftry>

<cftry>
      <cffile
            action="move"
            source="#globals.dir#clients\#icid#\resources\#FORM.templateTitlebarBackgroundImage#"
            destination="#newDir#\">
      <cfcatch type="any"></cfcatch>
</cftry>                        
                        
<cftry>
      <cffile
            action="move"
            source="#globals.dir#clients\#icid#\resources\#FORM.templateCloseButtonNormalImage#"
            destination="#newDir#\">
      <cfcatch type="any"></cfcatch>
</cftry>

<cftry>
      <cffile
            action="move"
            source="#globals.dir#clients\#icid#\resources\#FORM.templateCloseButtonOverImage#"
            destination="#newDir#\">
      <cfcatch type="any"></cfcatch>
</cftry>

<cftry>
      <cffile
            action="move"
            source="#globals.dir#clients\#icid#\resources\#FORM.templateCloseButtonDownImage#"
            destination="#newDir#\">
      <cfcatch type="any"></cfcatch>
</cftry>


0
Comment
Question by:questhaven
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
incapital earned 500 total points
ID: 17133522
The lack of error messages is probably due to the empty cfcatch blocks on your page. You might want to remove those, or put a <cfdump var="#cfCatch#"> in there to output any errors encountered while processing the request.

You might also want to try setting a value for the nameconflict parameter, such as nameconflict="ERROR". It's possible that the attempts are failing because there is a similarly named file in the target directory.
0
 

Author Comment

by:questhaven
ID: 17133701
Ok - I added the nameconflict="overwrite" and a <cfdump var="#cfCatch#"> in between the first <cffile> call and these are the results (keeping in mind that this is working sometimes, and other times it is not). I find it weird because I am currently just moving files from one directory to another directory both located on my local machine - so I don't know why Access would be denied.

Occurs on the line where the files start out:
 C:\Inetpub\wwwroot\apps\dp\clients\66\resources (Access is denied)

Occurs when I try and move the file to the other directory:  
 Application Exception - in C:\Inetpub\wwwroot\apps\dp\index.cfm
 Attribute validation error for tag CFFILE.

I'm not seeing any type of attribute error in the CFFILE tag.  Any ideas?
0
 
LVL 18

Expert Comment

by:Plucka
ID: 17136358
questhaven,

nameconflict is only for upload, not for move.

Check if the destination existis already and delete if it does.

<cfif fileExists("fileandpath")>
    <cffile action="delete" file="fileandpath" />
</cfif>
Make sure the destination directories exist also.

Regards
Plucka
0
 

Author Comment

by:questhaven
ID: 17148004
Thanks for everyones help, but It looks like my problem was that I was resizing the files using ImageUtils prior to moving them and there was an issue with the name not being changed after the resizing.  Once I made that change, things worked beautifully.  I did run into a small problem using ImageUtils when resizing - it seems that it can only handle a certain amount of images (for me the limit seems to be 5) before I need to call imageProcessor = createObject( "java", "ImageUtils" ); again.  Has anyone had any experience with this happening or know what might cause the problem?
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now