Skip to content

Instantly share code, notes, and snippets.

@tapioca2
Last active February 18, 2016 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tapioca2/fb9cfb0c34ec71ebc508 to your computer and use it in GitHub Desktop.
Save tapioca2/fb9cfb0c34ec71ebc508 to your computer and use it in GitHub Desktop.
CF Upload Multiple Files
<form action="productupload.cfm" enctype="multipart/form-data" name="upload_form" method="post">
<input type="file" name="upfile1"> (Main)
<input type="file" name="upfile2"> (photo 2)
<input type="submit" class="button blue medium" name="upload" value="Upload Photos" onclick="document.upload_form.upload.value='Please wait...';document.upload_form.upload.disabled=true;document.upload_form.submit();">
<input type="button" class="button white medium" value="Reset" onclick="document.upload_form.upload.disabled=false;document.upload_form.upload.value = 'Upload Photos';">
</form>
<cfinclude template="../template/currentpath.cfm">
<cftry>
<cffile action="uploadall" destination="#currentpath#" accept="image/jpeg, image/gif, image/png" nameconflict="makeunique">
<cfset accepted="true">
<cfcatch type="any">
<cfset accepted="false">
</cfcatch>
</cftry>
<cfif accepted>
<cfdump var="#cffile#">
<cfabort>
<cfelse>
...
</cfif>
<cfinclude template="../template/currentpath.cfm">
cfloop index = "i" from = "1" to = "1">
<cfif len(trim(form.upfile#i#)) gt 0>
<cftry>
<cffile action="uploadall" destination="#currentpath#" accept="image/jpeg, image/gif, image/png" fileField="form.upfile#i#" nameconflict="makeunique">
<cfset accepted="true">
<cfcatch type="any">
<cfset accepted="false">
</cfcatch>
</cftry>
<cfif accepted>
do some process
<cfelse>
put out error
</cfif>
</cfif>
</cfloop>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment