Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

looping in a cfhttp

New Here ,
Mar 19, 2009 Mar 19, 2009
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.
421
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Mar 20, 2009 Mar 20, 2009
use the associative array syntax:

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

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Guest
Mar 20, 2009 Mar 20, 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 20, 2009 Mar 20, 2009
use the associative array syntax:

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

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 22, 2009 Mar 22, 2009
LATEST
Thanks Azadi, worked perfectly.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources