User Guide

Table Of Contents
Using cffile 1009
Moving, renaming, copying, and deleting server files
With
cffile, you can create application pages to manage files on your web server. You can use
the tag to move files from one directory to another, rename files, copy a file, or delete a file.
The examples in the following table show static values for many of the attributes. However, the
value of all or part of any attribute in a
cffile tag can be a dynamic parameter.
contentSubType MIME content subtype of the saved file; for example, gif for image/gif.
dateLastAccessed Date that the uploaded file was last accessed.
fileExisted Indicates (Yes or No) whether the file already existed with the same path.
fileSize Size of the uploaded file.
fileWasAppended Indicates (Yes or No) whether ColdFusion appended the uploaded file to
an existing file.
fileWasOverwritten Indicates (Yes or No) whether ColdFusion overwrote a file.
fileWasRenamed Indicates (Yes or No) whether the uploaded file was renamed to avoid a
name conflict.
fileWasSaved Indicates (Yes or No) whether ColdFusion saved the uploaded file.
oldFileSize Size of the file that was overwritten in the file upload operation. Empty if
no file was overwritten.
serverDirectory Directory where the file was saved on the server.
serverFile Full name of the file saved on the server with the file extension; for
example, myfile.txt.
serverFileExt Extension of the file saved on the server without a period; for example, txt
(not .txt).
serverFileName Name of the file saved on the server without an extension; for example,
myfile.
timeCreated Date and time the uploaded file was created.
timeLastModified Date and time of the last modification to the uploaded file.
Action Example code
Move a file
<cffile action="move"
source="c:\files\upload\KeyMemo.doc"
destination="c:\files\memo\">
Rename a file
<cffile action="rename"
source="c:\files\memo\KeyMemo.doc"
destination="c:\files\memo\OldMemo.doc">
Copy a file
<cffile action="copy"
source="c:\files\upload\KeyMemo.doc"
destination="c:\files\backup\">
Delete a file
<cffile action="delete"
file="c:\files\upload\oldfile.txt">
Variable Description