ColdFusion Write File

Just as you can use ColdFusion to read a file from the server, you can also write a file to the server. You do this using the same tag you use to read files — the <cffile> tag.

Using the <cffile> tag, you can create a file, call it what you like, and fill it with whatever content you like. The content could be a simple hardcoded string, or it could be the contents of a variable, or both.

Example of Writing a File

This example declares a variable, assigns the current date and time to it, then writes the result to a file.

Other Attributes

Here's the full syntax of <cffile="upload">:

For a more detailed explanation, see Adobe's documentation for cffile="write".