Solved

Problem with using CFFile to move files

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

Give your grad a cloud of their own!

With up to 8TB of storage, give your favorite graduate their own personal cloud to centralize all their photos, videos and music in one safe place. They can save, sync and share all their stuff, and automatic photo backup helps free up space on their smartphone and tablet.

Question has a verified solution.

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

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…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

23 Experts available now in Live!

Get 1:1 Help Now