File Uploading with the CFFILE Tag Using the CFFILE Extension (continued)

 by Tom Muck

Step 6: Click OK and apply the behavior to the page. That is all there is to it!

A complete list of CFFILE built-in variables are accessible from the Data Bindings palette after applying the CFFILE Server Behavior to the page.

These built-in CFFILE variables can be dragged to the page or inserted with the Insert button. Also, you can use them inside of other Server Behaviors as Data Sources. A complete list of what each variable means is listed here:

Parameter Description
AttemptedServerFile

Initial name ColdFusion used attempting to save a file, for example, myfile.txt.

ClientDirectory

Directory location of the file uploaded from the client's system.

ClientFile

Name of the file uploaded from the client's system.

ClientFileExt

Extension of the uploaded file on the client's system without a period, for example, txt not .txt.

ClientFileName

Filename without an extension of the uploaded file on the client's system.

ContentSubType MIME content subtype of the saved file.
ContentType MIME content type of the saved file.
DateLastAccessed Date and time the uploaded file was last accessed.
FileExisted

Indicates (Yes or No) whether or not the file already existed with the same path.

FileSize

Size of the uploaded file.

FileWasAppended

Indicates (Yes or No) whether or not ColdFusion appended the uploaded file to an existing file.

FileWasOverwritten

Indicates (Yes or No) whether or not ColdFusion overwrote a file.

FileWasRenamed

Indicates (Yes or No) whether or not the uploaded file was renamed to avoid a name conflict.

FileWasSaved

Indicates (Yes or No) whether or not Cold Fusion saved a file.

OldFileSize

Size of a file that was overwritten in the file upload operation.

ServerDirectory

Directory of the file actually saved on the server.

ServerFile

Filename of the file actually saved on the server.

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.

Step 7: You should probably build some error checking into the page as well, which can be easily accomplished with a <cftry> block like this (hand-written code in bold):

<cftry>

<CFFILE action="upload"
 accept="image/gif"
 filefield="file"
 nameconflict="overwrite"
 destination="C:\InetPub\wwwroot\UD-cfmail\">

The file was successfully saved!
<cfcatch>
There was an error! Please go back and try again!
</cfcatch>
</cftry>

Tom Muck tommuck@basic-drumbeat.com

<<< Previous   Home>>>