Description
Copies all files sent to the page in an HTTP request to a directory on the server.
Syntax
<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" >
Note:
You can specify this tag's attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag's attribute names as structure keys.
ColdFusion (2018 release) Update 3, ColdFusion (2016 release) Update 10, ColdFusion 11 Update 18: Added the attribute allowedExtensions.
ColdFusion 11: Added the attributes ContinueOnError and Errors.
See the History section of the main
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 Values specified in the attribute allowedExtensions override the list of blocked extensions in the server or application settings. |
|
destination |
Required |
|
|
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 strict is true and 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"
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.
|
mode |
Optional |
|
Applies only to UNIX and Linux. Permissions. Octal values of
|
Optional |
Error |
Action to take if
|
|
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 1. Empty file In the case of an upload failure, the error details will be stored in the errors attribute. |
Errors | Optional | |
The name of the variable in which the file upload errors will be stored. Errors will be populated in the The upload failure information error structure contains the following fields:
|
result |
Optional |
|
Lets you specify a name for the variable in which |
strict | Optional | True |
strict="false" If strict is false, and 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 strict is false, and you try to upload a file, and the mime type is specified in the accept attribute, the file does not get uploaded. The file that you are trying to upload has it’s extension blocked in the Administrator/Application-level settings. For example,
strict="true" If strict is true and 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. |
Unlike cffile action="upload", which uploads only one file at a time cf fileaction="uploadall" uploads multiple files thereby eliminating the need to code multiple cffile action="upload" statements. Use this tag in the page specified by the action attribute of a cffileupload control. This tag uploads save the files that the cffileupload control sends when the user clicks the Save File button. After a file upload is completed, this tag creates an array of structures specified by the result parameter. Each structure in the array contains upload result information for one file. For information on the result structure contents, see cffile action = "upload".
Note:
You can control the maximum file size of the upload by specifying the server Request Throttle Threshold or the Settings page of the Administrator Server Settings section.
<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>