<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.

Usage

<cffile
    [charset=string]
    [mode=string]
    [createpath=boolean]
    [source=string]
    [fixnewline=boolean]
    [variable=string]
    [filefield=string]
    [serverpassword=string]
    [output=any]
    [strict=boolean]
    [accept=string]
    [nameconflict=string]
    [storeacl=object]
    [file=string]
    [addnewline=boolean]
    [destination=string]
    action=info|move|rename|copy|delete|read|readbinary|write|append|upload|uploadall|touch
    [result=string]
    [attributes=string]
    [cachedwithin=object]
><!--- body --->[</cffile>]

This tag may have a body.

This tag is also supported within cfscript

Attributes

Attribute Description
charset
(string, optional)

Character set name for the file contents.

mode
(string, optional)

Applies only to Solaris and HP-UX. Permissions. Octal values of UNIX chmod command. Assigned to owner, group, and other, respectively.

createpath
(boolean, optional)

for action "append", "touch" and "write": if set to false (default), expects all parent directories to exist, true will generate necessary directories

source
(string, optional)

Absolute pathname of file on web server. On Windows, use backward slashes; on UNIX, use forward slashes.

fixnewline
(boolean, optional)
  • 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.
variable
(string, optional)

Name of variable to contain contents of text file.

filefield
(string, optional)

Name of form field used to select the file.

serverpassword
(string, optional)

allow you to access filesystem, also when access is denied for your context

output
(any, optional)

Content of the file to be created.

strict
(boolean, optional)

for action "upload" and "uploadAll": if set to true (default), only mimetypes are supported.

accept
(string, optional)

list of supported extensions or/and mimetypes.

nameconflict
(string, optional)

Action to take if filename is the same as that of a file in the directory.

storeacl
(object, optional)

An array of struct where each struct represents a permission or grant. Example: [{email="xxx@yyy.com", permission="full_control"}, {group="all", permission="read"}]

file
(string, optional)

Absolute pathname of file on web server.

addnewline
(boolean, optional)

Yes: appends newline character to text written to file

destination
(string, optional)

Absolute pathname of directory or file on web server.

action
(string, required)

Type of file manipulation that the tag performs.

result
(string, optional)

Name of the result value (default:cffile)

attributes
(string, optional)

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.

cachedwithin
(object, optional)

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"

Examples

There are currently no examples for this tag.

See also