Solved

Problem with using CFFile to move files

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unable To Access a Web Domain From Our Network 16 86
Internal DNS Zone Issue 13 73
JKS to store upstart data 2 98
Help with a redirect in web.config file 8 42
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…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 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