Value
Uploads file to a directory on the server.
Struct that contains the result (or status) of file upload.For details of what the struct contains, see the usage section of cffile action = "upload".
FileUpload(destination, fileField, accept, nameConflict, strict, allowedExtensions)
ColdFusion (2018 release) Update 3, ColdFusion (2016 release) Update 10, ColdFusion 11 Update 18: Added the parameter allowedExtensions.
ColdFusion 9.0.1: Added this function.
|
Value |
Description |
|---|---|
|
destination |
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 |
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 override the list of blocked extensions in the server or application settings. |
|
nameConflict |
Action to take if file has the same name of a file in the directory.
|
|
allowedExtensions |
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 parameter allowedExtensions overrides the list of blocked extensions in the server or application settings. |
|
fileField |
Name of form field used to select the file. Do not use number signs (#) to specify the field name. |
|
strict |
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 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 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. |
<cfscript>
upload = FileUpload("C:\location\",
"fileData",
"text/x-coldfusion",
"Overwrite",
true,
".cfm, .png");
writeDump(upload);
</cfscript>
Sign in to your account