One of the simplest ways to test an expression is to write a piece of code that assigns an expression to a variable using the CFSET tag and then display the contents of the variable using CFOUTPUT. You can use this technique directly in the application page in which you are experiencing the problem.
The following example illustrates how to debug an expression using CFSET and CFOUTPUT. Imagine we are using a complex expression inside the DESTINATION attribute of the CFFILE tag.
<CFFILE ACTION="Upload"
FILEFIELD="FileFormField"
DESTINATION="ExpandPath('text.txt') & '\text.txt'">
To debug the expression, insert a simple CFSET and CFOUTPUT statement before the CFFILE tag:
<CFSET TempVariable=ExpandPath('text.txt') & '\text.txt'>
<CFOUTPUT>Destination="#TempVariable#"</CFOUTPUT>
This CFML code assigns the expression to a temporary variable (TempVariable) and displays it enclosed in quotes. The quotes are very useful when debugging string expressions in which unwanted spaces need to be detected.
The above test code results in the following page output.
"d:\webdocs\text.txt\text.txt"
The CFOUTPUT produces results that are easily interpreted. In this case, the error occurs because of the duplication of the filename at the end of the expanded path. Using the simple test script, the problem in the expression was resolved and the correct CFFILE tag was specified as:
<CFFILE ACTION="Upload"
FILEFIELD="FileFormField"
DESTINATION=ExpandPath("text.txt")>
|