Variable
fileWasSaved
oldFileSize
serverDirectory
serverFile
serverFileName
serverFileExt
timeCreated
timeLastModified
Moving, renaming, copying, and deleting server files
With
, you can create application pages to manage files on your web server. You can use
cffile
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.
Action
Move a file
Rename a file
Copy a file
Delete a file
This example sets the ReadOnly flag bit for the uploaded file:
<cffile action="Copy"
source="c:\files\upload\keymemo.doc"
destination="c:\files\backup\"
attributes="ReadOnly">
Note: Ensure you include the trailing slash (\) when you specify the destination directory. Otherwise,
ColdFusion treats the last element in the pathname as a filename. This only applies to copy actions.
Description
Indicates (Yes or No) whether ColdFusion saved the uploaded file.
Size of the file that was overwritten in the file upload operation. Empty if
no file was overwritten.
Directory where the file was saved on the server.
Full name of the file saved on the server with the file extension; for
example, myfile.txt.
Name of the file saved on the server without an extension; for example,
myfile.
Extension of the file saved on the server without a period; for example, txt
(not .txt).
Date and time the uploaded file was created.
Date and time of the last modification to the uploaded file.
Example code
cffile
<
action="move"
source="c:\files\upload\KeyMemo.doc"
destination="c:\files\memo\">
cffile
<
action="rename"
source="c:\files\memo\KeyMemo.doc"
destination="c:\files\memo\OldMemo.doc">
cffile
<
action="copy"
source="c:\files\upload\KeyMemo.doc"
destination="c:\files\backup\">
cffile
<
action="delete"
file="c:\files\upload\oldfile.txt">
Using cffile
825
Need help?
Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?
Questions and answers