User Guide
226 Developing Web Applications with ColdFusion
Use the File prefix to refer to these variables, for example, #CFFILE.FileExisted#.
Note File status variables are read-only. They are set to the results of the most
recent CFFILE operation. If two CFFILE tags execute, the results of the
first are overwritten by the subsequent CFFILE operation.
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 below 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. This makes
CFFILE a very powerful tool.
ServerFileExt Extension of the uploaded file on the server, without a
period, for example,
txt not.txt.
ServerFileName Filename, without an extension, of the uploaded file on
the server.
TimeCreated Time the uploaded file was created.
TimeLastModified Date and time of the last modification to the uploaded
file.
File Upload Variables (Continued)
Parameter Description
Examples of moving, renaming, copying, and deleting server files
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">