Throwing And Catching A File Using CFHttp For Both Actions

<!--- Kill extra output. --->
<cfsilent>
 
	<!---
		Param the form fields. Since this data is coming via
		a CFHTTP "Post" we can operate as if it was a standard
		form submission.
	--->
	<cfparam
		name="FORM.file"
		type="string"
		default=""
		/>
 
 
	<!--- Try to upload the file. --->
	<cftry>
 
		<!---
			Upload the file. When defining the CFFile, we can
			treat the posted file as if it was submitted via a
			standard File Input (since it was posted as a FILE
			using CFHttpParam).
		--->
		<cffile
			action="UPLOAD"
			filefield="file"
			destination="#ExpandPath( './files/' )#"
			nameconflict="MAKEUNIQUE"
			/>
 
 
		<!---
			Echo back the name of the file as it has been
			saved to the server.
		--->
		<cfcontent
			type="text/plain"
			variable="#ToBinary( ToBase64( CFFILE.ServerFile ) )#"
			/>
 
 
		<!---
			Catch any errors that were thrown during the
			file upload.
		--->
		<cfcatch>
 
			<!--- Echo back the error message. --->
			<cfcontent
				type="text/plain"
				variable="#ToBinary( ToBase64( CFCATCH.Message ) )#"
				/>
 
		</cfcatch>
	</cftry>
 
</cfsilent>

For Cut-and-Paste