Description

Uploads all files sent to the page in an HTTP request to a directory on the server.

Returns

An array of struct that provides the file upload status.For details of what the struct contains, see the Usage Section of cffile action = "uploadAll".

Function Syntax

FileUploadAll(destination,accept,nameConflict,continueOnError,errors)

History

ColdFusion 11: Added continueOnError and errors parameters.

ColdFusion 9.0.1: Added this function.

Parameters

Parameter Required Default Description
destination Required   Path 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, returned by the function getTempDirectory.
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. Comma-delimited list. For example, the following code permits JPEG and Microsoft Word file uploads:{{"image/jpg, application/msword"}}The browser uses the filename extension to determine file type.
nameConflict Optional Error

Action to take if file has the same name of a file in the directory.

  • Error: File is not saved. ColdFusion stops processing the page and returns an error.
  • Skip: File is not saved. Permits custom behavior based on file properties.
  • Overwrite: Replaces file.
  • MakeUnique: Forms a unique filename for the upload; name is stored in the file object variable serverFile.
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:

  • REASON - The reason for the failure
  • DETAIL - File upload failure detail
  • MESSAGE - A detailed message depicting the failure
  • CLIENTFILE - Name of the file uploaded from the client's system
  • CLIENTFILEEXT - Extension of the uploaded file on the client system (without a period)
  • CLIENTFILENAME - Name of the uploaded file on the client system (without an extension) 
  • INVALID_FILE_TYPE - If the file mime type or extension is not in the specified accept attribute. If the reason is INVALID_FILE_TYPE, two additional keys will be available in the structure. 
    • ACCEPT: list of mime types or file extensions given in the tag
    • MIMETYPE: mime type of the uploaded file
  • EMPTY_FILE - If the uploaded file is an empty file
  • FILE_EXISTS - If any file with the given name already exists in the destination and the overwritepolicy is error.
  • DEST - The destination where file is copied
  • FORM_FILE_NOT_FOUND - If the uploaded file is not found on the server.

See also

FileUpload

Usage

cffile action = "uploadAll"

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy