just like this

<cfset uploadResult = arrayNew(1)>
<cfloop from="1" to="5" index="img">

        <cfif Len(Trim(arguments["picture#img#"]))>
                <cftry>
                        <cffile action="upload" fieldname="arguments["picture#img#"]">
                        <cfset uploadResult[img] = CFFILE.ServerFile>
                        <cfcatch />
                </cftry>
        <cfelse
                <cfset uploadResult[img] = "">
        </cfif>
</cfloop>

then if you want to know what the uploaded file was for field 3, you would
call #uploadResult[3]#

easy?

Steve

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


Thanks for that, but how do you call the files using this way normall I
would use CFFILE.SERVERFILE? since they are whatever.tmp? and that's
what goes into the database blahblah.tmp? Where as b4 if I only had one
file it way easy to do, I did this code below...

Set
<cffile....>
<cfset attachment = CFFILE.SERVERFILE>

and Call or insert it later
#attachment#


Thanks


Carl



Steve Onnis wrote:

> number your file fields and pass them in like that
>
> <cfset args = structNew()>
> <cfset args.dbUpload = request.dbUpload>
> <cfset args.fileid = form.fileid>
> <cfset args.picture1 = form["picture1"]>
> <cfset args.picture2 = form["picture2"]>
> <cfset args.picture3 = form["picture3"]>
> <cfset args.picture4 = form["picture4"]>
> <cfset args.picture5 = form["picture5"]>
>
> <cfset args.ClientEmail = form.ClientEmail>
> <cfset args.EditorEmail = "form.EditorEmail">
>
> pass them in the same way
>
> then in your cfc just do a loop
>
> <cfloop from="1" to="5" index="img">
>       <cfif Len(Trim(arguments["picture#img#"]))>
>               <cftry>
>                       <cffile action="upload" fieldname="arguments["picture#img#"]">
>                       <cfcatch />
>               </cftry>
>       </cfif>
> </cfloop>
>
> Thats how i would do it
>
> Steve
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Carl
> Sent: Thursday, November 04, 2004 2:12 PM
> To: CFAussie Mailing List
> Subject: [cfaussie] Re: CFFILE Multiple Uploads using CFC
>
>
> Yeah sorry Steve I forgot to put that down, I pass the form fields from
> the form page, as I put in the original email. The thing is I can only
> get one file name to return/insert, instead of all of them if they were
> passed...I need to loop over the file names and put them into the
> respective field names in the DB...and I can work out how to pass them
> back to the return page with the results..  :)
>
>
> Info has been simplified for this example:
>
> <!--- Info getting passed from form --->
> <cfset args = structNew()>
>       <cfset args.dbUpload = request.dbUpload>
>       <cfset args.fileid = form.fileid>
>       <cfset args.picture1 = "picture1">
>       <cfset args.picture2 = "picture2">
>       <cfset args.picture3 = "picture3">
>       <cfset args.picture4 = "picture4">
>       <cfset args.picture5 = "picture5">
>
>       <cfset args.ClientEmail = form.ClientEmail>
>       <cfset args.EditorEmail = "form.EditorEmail">
>
>
> Defined Elsewhere:
> <cfset stUploadAttachment =
> uploadService.uploadFile(argumentCollection=args)>
>
> Thanks
>
> Carl
>
> Steve Onnis wrote:
>
>
>>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/
>
>
>
>

---
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