Cutter (CF-Talk) wrote:
> 
> I'm seeing two different things happening here. In one instance it says 
> <cffile action='copy' source='#thefullsourcefilepath#' 
> destination='#afulldestinationpathwithfilename#'>

copy with rename

> in another instance it reads like
> <cffile action='copy' source='#thefullsourcefilepath# 
> destination='#justapathwithoutafilename#'>

copy file to specific directory

> and yet another instance reads
> <cffile action='copy' source='#thefullsourcefilepath#' 
> destination='#justapathwithoutafilename#'>
> <cffile action='rename' source='#thisnewfilepathandname#' 
> destination='#samepathwithnewfilename#'>

copy with rename, but longer, and with more file I/O

> It seems to me that the first option makes the most sense. LiveDocs says 
> that action='copy' can take just a path or a path with filename for the 
> destination attribute, but if the intent of the code is to rename the 
> file in the new location anyway then option 1 seems like the best option.

Well certainly if you want to rename the file, the first option does 
make the most sense.  The third option only makes sense if you want to 
be sure the file gets copied but you're placing maybe some try/catch 
logic around the rename action.

If you aren't renaming the file, the first option also makes the most 
sense because if the last directory doesn't exist, it will fail.  In the 
second option, if the destination directory doesn't exist (assuming you 
didn't tack on a trailing /) it might actually do the copy but rename it 
to whatever the directory was.

ie...

/home/me/www/foo/test.html (file)
/home/me/www/foo2/

<cffile action="copy" source="/home/me/www/foo/test.html" 
destination="/home/me/www/foo3">

this would create a copy of "test.html" with a NEW filename of "foo3" in 
the "/home/me/www" directory.

While option 1:

<cffile action="copy" source="/home/me/www/foo/test.html" 
destination="/home/me/www/foo3/test.html">

Would cause an error.

I think. ;)

I always use the full destination path, personally.

Rick

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232275
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to