Solved

Problem with using CFFile to move files

Posted on 2006-07-18
5
701 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
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…

830 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