ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Internet & the Web

How To Upload Multiple Files With ColdFusion

Updated on October 14, 2012

Sometimes, you may need to have a customer, client or co-worker upload a single file or muliple files to the server for processing from a single online form. You could accomplish this by just letting the user upload multiple times with the same form, but we can make it a more simple stream line user interface, by allowing the user to select one or more files and upload using one submit button, or one instance of an online form.


The code below allows the user to select up to 5 files to upload to the server.

<cfform action="?uploadfiles=Yes&requesttimeout=600"
<table border=0 cellpadding=0 cellspacing=2>
<td valign=top align=right class="standard-content">FILE 1:</td>
<td valign=top><cfINPUT NAME="File1" TYPE="file" style="FONT-SIZE: 10px" required="yes" message="Please provide FILE 1"></td></tr>
<td valign=top align=right class="standard-content">FILE 2:</td>
<td valign=top><cfINPUT NAME="File2" TYPE="file" style="FONT-SIZE: 10px" ></td></tr>
<td valign=top align=right class="standard-content">FILE 3:</td>
<td valign=top><cfINPUT NAME="File3" TYPE="file" style="FONT-SIZE: 10px" ></td></tr>
<td valign=top align=right class="standard-content">FILE 4:</td>
<td valign=top><cfINPUT NAME="File4" TYPE="file" style="FONT-SIZE: 10px" ></td></tr>
<td valign=top align=right class="standard-content">FILE 5:</td>
<td valign=top><cfINPUT NAME="File5" TYPE="file" style="FONT-SIZE: 10px" ></td></tr>
<td colspan=2 valign=top class="standard-content" align="right"><input type="submit" value="Upload Files" style="FONT-SIZE: 10px"></td></tr>


The following code, assigns a variable for the path to the location of where the files will be uploaded.
Loops through 5 times, to check for files being uploaded. The parameter of 5 can be changed, just be aware of the timeout issue of too many files being uploaded.

<cfif IsDefined('uploadfiles')>

<cfparam name="xDir" default="d:\InetPub\Domains\whatsite\www\upload\">
<cfloop index="i" from="1" to="5" step="1">

<cfset filename = "form.file" & #i#>

<cfif evaluate(variables.filename) neq "">
<CFFILE ACTION="upload" FILEFIELD="#variables.filename#" DESTINATION="#xDir#"





Submit a Comment

No comments yet.


This website uses cookies

As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: ""