CFFILE ACTION = UPLOAD | |||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Copies a file to a directory on the server. | |||||||||||||||||||||||||||||||||||||||||||||||||||
Syntax<cffile action = "upload" fileField = "formfield" destination = "full_path_name" nameConflict = "behavior" accept = "mime_type/file_type" mode = "permission" attributes = "file_attribute_or_list"> | |||||||||||||||||||||||||||||||||||||||||||||||||||
See also
cfdirectory |
|||||||||||||||||||||||||||||||||||||||||||||||||||
History
New in ColdFusion MX: A directory path that you specify in the destination attribute does not require a trailing slash. New in ColdFusion MX: on Windows platforms, the temporary, archive, and system options of the attributes attribute are deprecated. Do not use them in new applications. They might not work, and might cause an error, in later releases.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
Usage
After a file upload is completed, you can get status information using file upload parameters. The status parameters use the cffile prefix; for example, cffile.clientDirectory. Status parameters can be used anywhere other ColdFusion parameters can be used.
The following file upload status parameters are available after an upload.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
Example
The following example creates a unique filename, if there is a name conflict when the file is uploaded on Windows: <cffile action = "upload" fileField = "FileContents" destination = "c:\web\uploads\" accept = "text/html" nameConflict = "MakeUnique"> The following examples show the use of the mode attribute. The first example creates the file /tmp/foo with permissions defined as: owner=read/write, group=read, other=read. <cffile action = "write" file = "/tmp/foo" mode = 644 output = "some text"> This example appends to a file and sets permissions to read/write (rw) for all. <cffile action = "append" destination = "/home/tomj/testing.txt" mode = 666 output = "Is this a test?"> This example uploads a file and sets permissions to owner/group/other = read/write/execute. <cffile action = "upload" fileField = "fieldname" destination = "/tmp/program.exe" mode = 777> |
ACTION | |
Required | |
Type of file manipulation that the tag performs. |
FILEFIELD | |
Required | |
Name of form field used to select the file. Do not use pound signs (#) to specify the field name. |
DESTINATION | |
Required | |
Absolute pathname of directory or file on web server. ColdFusion 5 and earlier: trailing slash in directory path is required. ColdFusion MX: trailing slash in directory path is optional. On Windows, use backward slashes; on UNIX, use forward slashes. |
NAMECONFLICT | |
Optional | |
Default value: "Error"
Action to take if filename is the same as that of a file in the directory.
|
ACCEPT | |
Optional | |
Limits the MIME types to accept. Comma-delimited list. For example, to permit JPG and Microsoft Word file uploads: accept = "image/jpg, application/msword" The browser uses file extension to determine file type. |
MODE | |
Optional | |
Applies only to Solaris and HP-UX. Permissions. Octal values of chmod command. Assigned to owner, group, and other, respectively. For example:
|
ATTRIBUTES | |
Optional | |
One attribute (Windows) or a comma-delimited list of attributes (other platforms) to set on the file. If omitted, the file's attributes are maintained. Each value must be specified explicitly. For example, if you specify attributes = "readOnly", all other attributes are overwritten.
|