User Guide
126 Chapter 2: ColdFusion Tags
Tip: To refer to parameters, use the cffile prefix: for example, #cffile.fileExisted#.
Note: File status parameters are read-only. They are set to the results of the most recent cffile
operation. (If two cffile tags execute, the results of the second overwrite the first.)
Example
The following example creates a unique filename, if there is a name conflict when the file is
uploaded on Windows:
<cffile action = "upload"
fileField = "FileContents"
destination = "c:\web\uploads\"
accept = "text/html"
nameConflict = "MakeUnique">
The following examples show the use of the mode attribute. The first example creates the file
/tmp/foo with permissions defined as: owner=read/write, group=read, other=read.
<cffile action = "write"
file = "/tmp/foo"
mode = 644
output = "some text">
This example appends to a file and sets permissions to read/write (rw) for all.
<cffile action = "append"
destination = "/home/tomj/testing.txt"
mode = 666
output = "Is this a test?">
This example uploads a file and sets permissions to owner/group/other = read/write/execute.
<cffile action = "upload"
fileField = "fieldname"
destination = "/tmp/program.exe"
mode = 777>
fileWasSaved Whether ColdFusion saves a file (Yes or No)
oldFileSize Size of a file that was overwritten in the file upload operation
serverDirectory Directory of the file saved on the server
serverFile Filename of the file saved on the server
serverFileExt Extension of the uploaded file on the server (without a period)
serverFileName Name of the uploaded file on the server (without an extension)
timeCreated Time the uploaded file was created
timeLastModified Date and time of the last modification to the uploaded file
Parameter Description