Skip to main content
Participant
March 20, 2009
Answered

looping in a cfhttp

  • March 20, 2009
  • 2 replies
  • 469 views
Hi All,

I've got a form that can have as many files uploaded at a time as the user needs. I am then sending those files off to a different server using cfhttp.

I have the total number of files passed over by the form.

I want to loop through to send all the files but i can't get the dynamic file names to work. This is what i've got.

<cfloop index="i" from="1" to="#FORM.totalImages#">
<cfhttpparam name="image#i#" type="file" file="#FORM.image##i#">
</cfloop>


Any help would be appreciated.
    This topic has been closed for replies.
    Correct answer Newsgroup_User
    use the associative array syntax:

    file="#FORM['image' & i]#"

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/

    2 replies

    Newsgroup_UserCorrect answer
    Inspiring
    March 21, 2009
    use the associative array syntax:

    file="#FORM['image' & i]#"

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    WEBDavidAuthor
    Participant
    March 22, 2009
    Thanks Azadi, worked perfectly.
    March 21, 2009
    I'm thinking you need:

    <cfloop index="i" from="1" to="#listlen(FORM.totalImages)#">

    listlen will return the number of items in your list, i.e. telling the loop how many times to loop.

    cfwild