cfdocs.org /

Description

Appends text to a text file on the server.

Syntax

<cffile  
    action = "append" 
    file = "full pathname" 
    output = "string" 
    addNewLine = "yes|no" 
    attributes = "file attributes list" 
    charset = "characterset option"  
    fixnewline = "yes|no" 
    mode = "mode">
Note: You can specify this tag’s attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag’s attribute names as structure keys.

See also

cfdirectory

History

See the History section of the main cffile tag page.

Attributes

Attribute

Req/Opt

Default

Description

action

Required

Type of file manipulation that the tag performs.

file

Required

Pathname of the file to which to append content of output attribute.

If not an absolute path (starting with a drive letter and a colon, or a forward or backward slash), it is relative to the ColdFusion temporary directory, which is returned by the GetTempDirectory function.

output

Required

String to append to the file.

addNewLine

Optional

yes

  • yes: appends newline character to text written to file.

  • no

attributes

Optional

Applies to Windows. A comma-delimited list of attributes to set on the file.

If omitted, the file’s attributes are maintained.

Each value must be specified explicitly. For example, if you specify attributes="readOnly", all other attributes are overwritten.

  • readOnly

  • hidden

  • normal

charset

Optional

JVM default file character set

The character encoding in which the file contents is encoded. The following list includes commonly used values:

  • utf-8

  • iso-8859-1

  • windows-1252

  • us-ascii

  • shift_jis

  • iso-2022-jp

  • euc-jp

  • euc-kr

  • big5

  • euc-cn

  • utf-16

For more information character encodings, see www.w3.org/International/O-charset.html.

fixnewline

Optional

No

  • yes: changes embedded line-ending characters in string variables to operating-system specific line endings

  • no: (default) do not change embedded line-ending characters in string variables.

For an example that uses this attribute, see cffile action = "write".

mode

Optional

Applies only to UNIX and Linux. Permissions. Octal values of UNIX chmod command. Assigned to owner, group, and other, respectively; for example:

  • 644: assigns read/write permission to owner; read permission to group and other.

  • 777: assigns read/write/execute permission to all.

Example

<!--The first example creates the file \temp\foo on a windows system and sets attributes to normal. ---> 
<cffile action = "write" file = "\temp\foo" attributes = normal output = "some text">  
 
<!--- The second example appends to the file. ---> 
<cffile action = "append" file = "\temp\foo" attributes = normal output = "Is this a test?">