Evaluating the results of a file upload

After a file upload is completed, you can retrieve status information using file upload status variables. This status information includes data about the file, such as its name and the directory where it was saved.

You can access file upload status variables using dot notation, using either file.varname or cffile.varname. Although you can use either the File or cffile prefix for file upload status variables, cffile is preferred; for example, cffile.ClientDirectory. The File prefix is retained for backward compatibility.

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.

The following table describes the file upload status variables that are available after an upload:

Variable

Description

attemptedServerFile

Initial name that ColdFusion uses when attempting to save a file; for example, myfile.txt. (see Resolving conflicting filenames).

clientDirectory

Directory on the client’s system from which the file was uploaded.

clientFile

Full name of the source file on the client’s system with the file extension; for example, myfile.txt.

clientFileExt

Extension of the source file on the client’s system without a period; for example, txt (not .txt).

clientFileName

Name of the source file on the client’s system without an extension; for example, myfile.

contentType

MIME content type of the saved file; for example, image for image/gif.

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.