<CFFILE ACTION="Upload" FILEFIELD="formfield" DESTINATION="directory" NAMECONFLICT="behavior" ACCEPT="file_extension" MODE="permission" ATTRIBUTES="file_attributes">
Use CFFILE with the Upload action to upload a file specified in a form field to a directory on the Web server.
Note that the MODE attribute applies only to ColdFusion on Solaris.
Required. The name of the form field that was used to select the file.
Note: Do not use pound signs (#) to specify the field name.
Required. The destination directory on the Web server where the file should be saved.
Note: The directory does not need to be beneath the root of the Web server document directory.
Optional. Default is error. Determines how the file should be handled if its name conflicts with the name of a file that already exists in the directory. Valid entries are:
Optional. Use to limit what types of files will be accepted. Enter one or more MIME types, each separated by comma, of the file types you want to accept. For example, to allow uploads of GIF and Microsoft Word files, enter:
ACCEPT="image/gif, application/msword"
Note: The browser uses the file extension to determine file type.
Optional. Defines permissions for an uploaded file in Solaris. Ignored in Windows. Valid entries correspond to the octal values (not symbolic) of the UNIX chmod command. Permissions are assigned for owner, group, and other, respectively. For example:
MODE=644
Assigns the owner read/write permissions and group/other read permission.
MODE=666
Assigns read/write permissions for owner, group, and other.
MODE=777
Assigns read, write, and execute permissions for all.
Optional. A comma-delimited list of file attributes to be set on the file being uploaded. The following file attributes are supported:
If ATTRIBUTES is not used, the file's attributes are maintained. If Normal is specified as well as any other attributes, Normal is overridden by whatever other attribute is specified.
Individual attributes must be specified explicitly. For example, if you specify just the ReadOnly attribute, all other existing attributes are overwritten.
The following example will create a unique filename if there is a name conflict when the file is uploaded:
<CFFILE ACTION="Upload" FILEFIELD="FileContents" DESTINATION="c:\web\uploads\" ACCEPT="text/html" NAMECONFLICT="MakeUnique">
This following three examples show the use of the MODE attribute for UNIX. The first example creates the file /tmp/foo
with permissions defined as rw-r-r
-- (owner=read/write, group/other=read).
<CFFILE ACTION="Write" FILE="/tmp/foo" MODE=644>
This example appends to the specified file and makes permissions read/write (rw) for all.
<CFFILE ACTION="Append" DESTINATION="/home/tomj/testing.txt" MODE=666 OUTPUT="Is this a test?">
The next example uploads a file and gives it rwx-rw-rw
permissions (owner/group/other=read/write).
CFFILE ACTION="Upload" FILEFIELD="fieldname" DESTINATION="/tmp/program.exe" MODE=755>