Lucee Tag Reference

<cffile>

Handles all interactions with files. The attributes you use with cffile depend on the value of the action attribute. For example, if the action = "write", use the attributes associated with writing a text file.

Body

This tag may have a body.

Example

<cffile
[accept=string]
action=info|move|rename|copy|delete|read|readbinary|write|append|upload|uploadall|touch
[addnewline=boolean]
[allowedextensions=any]
[attributes=string]
[blockedextensions=any]
[cachedwithin=object]
[charset=string]
[createpath=boolean]
[destination=string]
[file=string]
[filefield=string]
[fixnewline=boolean]
[mode=string]
[nameconflict=string]
[output=any]
[result=string]
[serverpassword=string]
[source=string]
[storeacl=object]
[strict=boolean]
[variable=string]>
[</cffile>]
This tag is also supported within cfscript
<cfscript>
file
[accept=string]
action=info|move|rename|copy|delete|read|readbinary|write|append|upload|uploadall|touch
[addnewline=boolean]
[allowedextensions=any]
[attributes=string]
[blockedextensions=any]
[cachedwithin=object]
[charset=string]
[createpath=boolean]
[destination=string]
[file=string]
[filefield=string]
[fixnewline=boolean]
[mode=string]
[nameconflict=string]
[output=any]
[result=string]
[serverpassword=string]
[source=string]
[storeacl=object]
[strict=boolean]
[variable=string] {
[...]
}
</cfscript>

Attributes

The attributes for this tag are fixed. Except for the following attributes no other attributes are allowed.
Name Type Required Description
accept string No list of supported extensions or/and mimetypes. 
action string Yes Type of file manipulation that the tag performs. 
addnewline boolean No Yes: appends newline character to text written to file 
allowedextensions any No String list or string array of extensions allowed, this overwrites any other setting including the attribute [blockedExtensions] and settings done for example in the Application.cfc. 
attributes string No One attribute (Windows) or a comma-delimited list of attributes (other platforms) to set on the file.
If omitted, the file's attributes are maintained. 
blockedextensions any No String list or string array of extensions blocked, this overwrites any setting done for example in the Application.cfc. 
cachedwithin any No possible values are:
String "request": If original content was created within the current request, cached content data isused.
a timespan (created with function CreateTimeSpan): If original content date falls within the time span, cached content data isused.

To use cached data, the tag must be called with the exact same arguments. Only used by action "read" and "readbinary" 
Introduced: 5.0.0.0
charset string No Character set name for the file contents. 
createpath boolean No for action "append", "touch" and "write":
if set to false (default), expects all parent directories to exist, true will generate necessary directories 
destination string No Absolute pathname of directory or file on web server. 
file string No Absolute pathname of file on web server. 
filefield string No Name of form field used to select the file. 
fixnewline boolean No - true: changes embedded line-ending characters in string
variables to operating-system specific line endings
- false: (default) do not change embedded line-ending
characters in string variables. 
mode string No Applies only to Solaris and HP-UX. Permissions. Octal values of UNIX chmod command. Assigned to owner, group, and other, respectively. 
nameconflict string No Action to take if filename is the same as that of a file in the directory. 
output any No Content of the file to be created. 
result string No Name of the result value (default:cffile) 
serverpassword string No allow you to access filesystem, also when access is denied for your context 
source string No Absolute pathname of file on web server.
On Windows, use backward slashes; on UNIX, use forward slashes. 
storeacl any No An array of struct where each struct represents a permission or grant.
Example:
[{email="xxx@yyy.com", permission="full_control"}, {group="all", permission="read"}] 
strict boolean No for action "upload" and "uploadAll":
if set to true (default), only mimetypes are supported. 
variable string No Name of variable to contain contents of text file.