This page shows you the code used to generate the form on the Multiple Uploads demo page.


<cfimport taglib="/tags/forms/cfUniForm" prefix="uform" />

<cfloop from="1" to="4" index="i">
 <cfif structKeyExists(form,"file" & i) AND len(trim(form["file" & i])) GT 0>
  <cfscript>
   filefield = "file" & i;
   uploadpath = getDirectoryFromPath(getCurrentTemplatePath());
  </cfscript>
  <cffile action="upload" filefield="#filefield#" destination="#uploadpath#" nameconflict="overwrite" />
 </cfif>
 
 <cfif structKeyExists(form,"anotherfile" & i) AND len(trim(form["anotherfile" & i])) GT 0>
  <cfscript>
   filefield = "anotherfile" & i;
   uploadpath = getDirectoryFromPath(getCurrentTemplatePath());
  </cfscript>
  <cffile action="upload" filefield="#filefield#" destination="#uploadpath#" nameconflict="overwrite" />
 </cfif>
</cfloop>
<div class="cfUniForm-form-container">
 <uform:form action="#cgi.script_name#"
    id="myDemoForm"
    submitValue=" Upload "
    loadjQuery="true"
    loadValidation="true">
 
  <p>
   This form utilizes cfUniForm's native type="file" tag.
  </p>
  <uform:fieldset legend="Files to Upload" class="inlineLabels">
   <cfloop index="i" from="1" to="4" step="1">
    <cfset filename = "file" & i />
    <uform:field label="File ##i#"
       name="#filename#"
       isRequired="false"
       type="file" />
   </cfloop>
  </uform:fieldset>
  
 </uform:form>
</div>

<div class="cfUniForm-form-container">
 <uform:form action="#cgi.script_name#"
    id="myDemoForm"
    enctype="multipart/form-data"
    submitValue=" Upload "
    loadjQuery="true"
    loadValidation="true">
 
  <p>
   This form utilizes cfUniForm's type="custom" tag in conjunction 
   with standard XHTML file fields.
  </p>
  <uform:fieldset legend="Files to Upload" class="inlineLabels">
   <uform:field type="custom">
    <cfoutput>
    <label for="anotherfile1">Upload File(s)</label>
    <cfloop index="i" from="1" to="4" step="1">
     <cfset filename = "file" & i />
     <cfif i GT 1>
      <label for="anotherfile#i#">&nbsp;</label>
     </cfif>
     <input name="anotherfile#i#" id="anotherfile#i#" size="35" type="file" class="fileUpload" />
    </cfloop>
    </cfoutput>
   </uform:field>
  </uform:fieldset>
  
 </uform:form>
</div>