This page shows samples of how the FileDump function for ColdFusion works.
You can Download the function at the bottom of the page.

This function will allow you to use the CFDUMP command to write the contents of a variable to a file. This is useful for capturing the value of a variable from within a page that gets redirected or for error tracking within a <CFTRY> block.

FileDump was actually written by a coworker - Noah Sepsenwol. I asked him if I could include it on my site as long as I gave him credit and here is his reply:

    Sure. Be sure to give credit to my parents and grandparents as well.
So thanks Noah, and your entire lineage!

 
Download fileDump() function:


<!--- ============ FILEDUMP ============== --->
<CFFUNCTION name="fileDump" output="no" hint="CFDump to a HTML file. If no filename, outputs to 'filedump.html' in the current folder. Useful in debugging AbleCommerce redirects">
<CFARGUMENT name="var" type="any" required="No">
<CFARGUMENT name="fyl" type="string" required="No" default="#GetDirectoryFromPath(GetBaseTemplatePath())#filedump.html">
<CFARGUMENT name="action" type="string" required="No" default="WRITE">
    
<!---
	###################################################
	## Author: Noah Sepsenwol & George Jaros         ##
	## Script Name: ColdFusion FileDump Function     ##
	## Copyright 2006 Noah Sepsenwol, George Jaros   ##
	## & Web 2 Market                                ##
	## www.georgejaros.com  www.web2market.com       ##
	## This code may be replicated as long as        ##
	## this header statement is included.  The       ##
	## Instructions below may be removed.            ##
	## History:                                      ##
	##  11.20.2006                                   ##
	##  Add optional param "action"                  ##
	##   {"write"|"append", default "write"}         ##
	##   If "append", will create the file if no file##
	##   exists.                                     ##
	###################################################
--->
<!--- 
	CFDump to a HTML file. If no filename, outputs to 'filedump.html' in the current folder. Useful in debugging redirects.

	Usage: <cfset fileDump( someVariable )> 
	       <cfset fileDump( someVariable, "somevariableDebug.html" )> 
	       <cfset fileDump( someVariable, "somevariableDebug.html", "APPEND" )> 
--->


	<CFSAVECONTENT variable="dumpvar">
	    <CFDUMP var="#var#">
	</CFSAVECONTENT>
	
	<CFIF Action EQ "append" AND NOT FileExists( fyl )>
	    <CFFILE file="#fyl#" action="WRITE" output="" addnewline="No">
	</CFIF>
	
	<CFFILE file="#fyl#" action="#action#" output="#dumpvar#" addnewline="Yes">
    
</CFFUNCTION>
<!--- ============ END FILEDUMP ============== --->

eXTReMe Tracker