I am trying to pass a file type form field to CFFUNCTION. The argument type is "any". Here is the syntax I'm 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 executed because there are five form fields with the name "attachment1", "attachment2", etc.
This raises an exception in the function:
coldfusion.tagext.io.FileTag$FormFileNotFoundException: The form field C:\ColdFusion8\...\neotmp25080.tmp did not contain a file.
However, this DOES syntax works:
<cfloop from="1" to="5" index="i">
<cfinvoke component="myComponent" method="attachFile">
<cfinvokeargument name="attachment" value="FORM.attachment#i#" />
</cfinvoke>
</cfloop>
I do not like to write such code in the second example. This seems like bad practice to me.
So, can someone tell me how to use the structure syntax to correctly pass the file type form field to CFFUNCTION?
source
share