Here's the snippet of code I use to upload files. I just pass the name
of the form field to the upload function.

I've used the same approach for years with Fusebox and CFModule. It
works great. I have a couple of dozen applications that all use the
same code to upload files.

        <cffunction name="upload" returntype="ManagedFile">
                <cfargument name="fieldname" type="string" required="true">
                <cfset var f = createObject('component', 'ManagedFile').init()>
                <cffile action="UPLOAD"
                        accept="#variables.acceptedContentTypes#"
        filefield="#arguments.fieldName#"
        destination="#variables.destinationPath#"
        nameconflict="MAKEUNIQUE">
                <cfset f.setName(CFFILE.clientFile)>
                <cfset f.setPath(CFFILE.serverDirectory & "\" & 
CFFILE.serverfile)>
                <cfset f.setContentType(CFFILE.contentType)>
                <cfset f.setSize(CFFILE.fileSize)>
                <cfset f.setCreatedDate(Now())>
                <cfreturn f>
        </cffunction>

I've tried Barney's technique of just copying the temp file as well.
One problem I had is that when you upload a text file CF just
poplulates the form field with the contents of that file. Though I was
able to work around that problem I think I went back to CFFILE
ACTION=UPLOAD because I could use the variables from the CFFILE tag
afterwards, particularly contentType and clientFileName.

HTH,

Patrick

-- 
Patrick McElhaney
704.560.9117
http://pmcelhaney.blogspot.com
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at 
[EMAIL PROTECTED]

Reply via email to