Going by how you are suposed to use CFC's, you should be doing the upload
outside the CFC because the CFFILE tag will only accept a FORM var and you
wont be able to use the Arguments var.

What i do is pass in the whole form structure, and re-assign it inside the
CFC itself, so it would look something like

<cfargument name="formObj" requires="Yes" type="Struct" />
<cfset thisForm = Arguments.formObj>

<cffile action="UPLOAD" fieldname="thisForm.fileField"...............

and so on

Just an idea for you

Steve

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Carl
Sent: Thursday, November 04, 2004 12:04 PM
To: CFAussie Mailing List
Subject: [cfaussie] CFFILE Multiple Uploads using CFC


Can someone share some info on multi file uploads using CFFILE. I want
to loop through the names of the files so that I can enter them into the
DB into their respective fields..All works fine but cannot work out how
to loop through the names...

Example below is simplified, real example has multiple file types such
as vids, pdf, and jpg's (which I can work out).

Form elements are form.picture1 through to form.picture5

<cfargument name="dbUpload" required="true">
<cfargument name="Clientemail" required="true" type="string">
<cfargument name="Picture1" type="string">
<cfargument name="Picture2" type="string">
<cfargument name="Picture3" type="string">
<cfargument name="Picture4" type="string">
<cfargument name="Picture5" type="string">


<cfset AcceptFileTypes = "image/jpg>

<cflock name="ClientUpload" type="EXCLUSIVE" timeout="5">
<cfset MyFieldList="Picture1,Picture2,Picture3,Picture4,Picture5">

<cfloop list="#MyFieldList#" index="ThisField">

<cfif IsDefined('Form.#ThisField#') AND Len(Form[ThisField])>

<CFFILE
  ACTION="UPLOAD"
  FileField="#ThisField#"
  Destination="#request.UploadDirectory#"
  NameConflict="OverWrite"
  accept="#AcceptFileTypes#">
</cfif>
</cfloop>

</cflock>


This is where I am having trouble...because they all finish at different
times based on size (I worked out how to do it with one file but not multi).

<cfset Picture1 = cffile.serverfile>
<cfset Picture2 = cffile.serverfile>
<cfset Picture3 = cffile.serverfile>
<cfset Picture4 = cffile.serverfile>
<cfset Picture5 = cffile.serverfile>




<cfquery datasource="#request.dsn#"
name="qUpload"
INSERT INTO #arguments.dbUpload#
        (File_ObjectID,
        File_Editor,
        File_Picture1,
        File_Picture2,
        File_Picture3,
        File_Picture4,
        File_Picture5,
        File_Referer,
        File_DateCreated,
        File_CreatedBy)
VALUES
        ('#arguments.FileId#',
        '#arguments.EditorEmail#',
        '#Picture1#',
        '#Picture2#',
        '#Picture3#',
        '#Picture4#',
        '#Picture5#',
        '#arguments.Desc#',
        '#arguments.referer#',
        #Now()#,
        '#arguments.ClientEmail#')
</cfquery>

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
[EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/



---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to