I am trying to let someone upload some image files into the 'images' folder
on their web site.  The trick is to get the file uploaded, clear out the
file it is replacing, and rename the new file to the name of the old one,
all while keeping the page 100% portable and without accidentaly overwriting
other image files.  Here is what I have so far.  I'm sure the syntax is way
off on a lot of this, but at least you can see what I am trying to do.  My
question is:

1.  Is there a better way to accomplish this?

<!--- make sure form field was filled in --->
<CFIF IsDefined('Form.filePicture2') AND Form.filePicture2 IS NOT "">
    <!--- check to see if the file already exists in 1 of 3 forms and if so,
delete it --->
    <CFIF FileExists(ExpandPath('../images/Home_Picture1.jpg'))>
        <CFFILE action="DELETE"
file="#ExpandPath('../images/Home_Picture2.jpg')#">
    </CFIF>
    <CFIF FileExists(ExpandPath(../images/Home_Picture1.jpeg))>
        <CFFILE action="DELETE"
file="#ExpandPath('../images/Home_Picture2.jpeg')#">
    </CFIF>
    <CFIF FileExists(ExpandPath(../images/Home_Picture1.gif))>
        <CFFILE action="DELETE"
file="#ExpandPath('../images/Home_Picture2.gif')#">
    </CFIF>
    <CFFILE action="UPLOAD" filefield="Form.filePicture2"
destination="ExpandPath('../images/temp')" nameconflict="MAKEUNIQUE"
accept="image/gif, image/jpg, imgage/jpeg">
    <CFFILE action="RENAME"
source="ExpandPath('../images/temp/#FILE.ServerFile#')"
destination="ExpandPath('../images/Home_Picture2.#FILE.ClientFileExt#')">
    <CFFILE action="DELETE"
file="ExpandPath('../images/temp/#FILE.ServerFile#')">
</CFIF>

.Todd


------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to