Solved

Problem with using CFFile to move files

Posted on 2006-07-18
5
704 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

729 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