Description
Uploads all files sent to the page in an HTTP request to a directory on the server.
Returns
An array of
Function Syntax
FileUploadAll(destination, accept, nameConflict, strict, continueOnError, errors, allowedExtensions)
History
ColdFusion (2018 release) Update 3, ColdFusion (2016 release) Update 10, ColdFusion 11 Update 18: Added the parameter allowedExtensions.
ColdFusion 11: Added continueOnError and errors parameters.
ColdFusion 9.0.1: Added this function.
Parameters
Parameter | Required | Default | Description |
destination | Required | Path of If the destination you specify does not exist, ColdFusion creates a file with the specified destination name. For example, if you specify the destination C:\XYZ, ColdFusion creates a file XYZ in the C: drive. |
|
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 the file that you are trying to upload has it’s extension blocked in the Administrator/Application-level settings, and the mime type is specified in the accept attribute, 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. |
|
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. |
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. |
|
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. |
errors | Optional | |
The name of the variable in which the file upload errors will be stored. Errors will be populated in the specified variable name when continueOnError is true The upload failure information error structure contains the following fields:
|
<cfscript> destination=GetDirectoryFromPath(GetCurrentTemplatePath()); acceptMimes="image/png, image/jpeg, text/x-coldfusion, text/plain, application/xml"; onConflict="MakeUnique"; strict = false; continueOnErr = false; errOnOps = ""; acceptExtensions = ".png, .cfm"; fileUploaded = FileUploadAll(destination, acceptMimes, onConflict, strict, continueOnErr, errOnOps, acceptExtensions); writeDump(fileUploaded); </cfscript>