Whatever message this page gives is out now! Go check it out!
<cffile
action = "uploadAll"
allowedExtensions="comma-separated list of file extensions"
destination = "full pathname"
accept = "list of MIME types"
attributes = "file attribute or list"
mode = "permission"
nameConflict = "behavior"
result = "result name"
ContinueOnError = "true|false"
Errors = Variable in which the file upload errors will be stored."
strict="true|false"
>Attribute | Req/Opt | Default | Description |
action | Required | Type of file manipulation that the tag performs. | |
| allowedExtensions | Optional | A comma-separated list of file extensions, which will be allowed for upload. For example, .png, .jpg, or, .jpeg. You can use "*" (star) to allow all files, except where you specify the MIME type in the accept attribute. Values specified in the attribute allowedExtensions override the list of blocked extensions in the server or application settings. | |
destination | Required | Pathname of directory in which to upload the file. If not an absolute path (starting 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. | |
accept | Optional | Limits the MIME types to accept. It is a comma-delimited list. For example, the following code permits JPEG and Microsoft Word file uploads:"image/jpg,application/msword". When strict="true" If the mime type is specified in the accept attribute, the file does not get uploaded if the extension is blocked in the server or application settings. When strict="false" If you provide a file extension in the attribute accept, the extension overrides the blocked extension list in the server or application settings. The file then gets uploaded. If you provide a MIME type in the attribute accept, and the extension of the file you are trying to upload is blocked in the Administrator/Application-level settings, the file does not get uploaded. For example,
Values specified in the attribute allowedExtensions overrides the list of blocked extensions in the server or application settings. | |
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.
| |
mode | Optional | Applies only to UNIX and Linux. Permissions. Octal values of chmod command. Assigned to owner , group, and other, respectively, for example:
| |
nameConflict | Optional | Error | Action to take if filename is the same as that of a file in the directory.
|
| ContinueOnError | Optional | False | By default, when uploading one of the files fail, the remaining files will not be uploaded. If this value is set to true, file upload continues evern after encountering an upload error. A file upload error happens due to the following reasons: 1. Empty file 2. Invalid file type 3. Invalid MIME or extension 4. File already exists In the case of an upload failure, the error details will be stored in the errors attribute. |
| Errors | Optional | cffile .uploadAllErrors | The name of the variable in which the file upload errors will be stored. Errors will be populated in the specfied variable name when continueOnError is true .After the file upload is completed, this tag creates an array of structures that contains upload failure information for each upload failure. The upload failure information error structure contains the following fields:
|
result | Optional | Lets you specify a name for the variable in which cffile returns the result (or status) parameters. If you do not specify a value for this attribute, cffile uses the prefix cffile . For more information, see Usage. | |
| strict | Optional | True | strict="false" If you provide a file extension in the attribute accept, the extension overrides the blocked extension list in the server or application settings. The file then gets uploaded. If you provide a MIME type in the attribute accept, and the extension of the file you are trying to upload is blocked in the Administrator/Application-level settings, the file does not get uploaded. For example,
strict="true" If the mime type is specified in the accept attribute, the file does not get uploaded if the extension is blocked in the server or application settings. For example, if you have blocked file type CFM in the ColdFusion Administrator and specified accept=”text/x-coldfusion” and strict=”true”, and you try uploading a cfm file, the file does not get uploaded. Values specified in the attribute allowedExtensions overrides the list of blocked extensions in the server or application settings. |
<cfform action="#cgi.script_name#" enctype="multipart/form-data">
<cfinput type="file" name="attachment1">
<cfinput type="file" name="attachment2">
<cfinput type="file" name="attachment3">
<cfinput type="submit" name=" submit" value="submit">
</cfform>
<cfif isdefined("form.submit")>
<cffile
action="uploadall"
destination="#expandpath(".")#"
nameconflict="MakeUnique"
accept="image/png,image/gif,.png,.gif"
strict="true"
result="fileUploaded"
allowedextensions=".png,.gif,.cfm"
>
<cfloop array="#fileUploaded#" item="item">
<br><cfdump var="#filegetmimetype(item.serverdirectory&'/'&item.serverfile)#">
<br><a href="<cfoutput>#item.serverfile#</cfoutput>"><cfoutput>#item.serverfile#</cfoutput></a>
</cfloop>
</cfif>