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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
See the History section of the main cffile tag page. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
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 | |
Pathname of directory in which to upload the file. If not an absolute path (starting a with a drive letter and a colon, or a forward or backward slash), it is relative to the ColdFusion temporary directory, which is returned by the GetTempDirectory function. |
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 UNIX and Linux. Permissions. Octal values of chmod command. Assigned to owner, group, and other, respectively. For example:
|
ATTRIBUTES | |
Optional | |
Applies to Windows. A comma-delimited list of attributes 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.
|