Why can't I pass a form field of type file to a CFFUNCTION using structure syntax?

Posted by Eric Belair on Stack Overflow See other posts from Stack Overflow or by Eric Belair
Published on 2010-05-04T13:35:26Z Indexed on 2010/05/04 13:38 UTC
Read the original article Hit count: 140

Filed under:
|
|
|

I'm trying to pass a form field of type "file" to a CFFUNCTION. The argument type is "any". Here is the syntax I am trying to use (pseudocode):

<cfloop from="1" to="5" index="i">
    <cfset fieldname = "attachment" & i />

    <cfinvoke component="myComponent" method="attachFile">
        <cfinvokeargument name="attachment" value="#FORM[fieldname]#" />
    </cfinvoke>
</cfloop>

The loop is being done because there are five form fields named "attachment1", "attachment2", et al.

This throws an exception in the function:

coldfusion.tagext.io.FileTag$FormFileNotFoundException: The form field C:\ColdFusion8\...\neotmp25080.tmp did not contain a file.

However, this syntax DOES work:

<cfloop from="1" to="5" index="i">
    <cfinvoke component="myComponent" method="attachFile">
        <cfinvokeargument name="attachment" value="FORM.attachment#i#" />
    </cfinvoke>
</cfloop>

I don't like writing code like that in the second example. It just seems like bad practice to me.

So, can anyone tell me how to use structure syntax to properly pass a file type form field to a CFFUNCTION??

© Stack Overflow or respective owner

Related posts about coldfusion

Related posts about cffunction