Currently I'm working on a project to convert source code from ColdFusion to Lucee. I found an error occurs in Lucee, when using FORM.getPartArray()
. Does Lucee have a similar function that can replace FORM.getPartArray()
?
Example code:
<cfset var fileExt = 'png'>
<cfset var tmpPartsArray = FORM.getPartsArray() />
<cfif IsDefined("tmpPartsArray")>
<cfloop array="#tmpPartsArray#" index="local.tmpPart">
<cfif local.tmpPart.isFile() AND local.tmpPart.getName() EQ arguments.formField>
<cfset fileExt = ListLast(local.tmpPart.getFileName(), ".")>
</cfif>
</cfloop>
</cfif>
You could also try FORM.getFileItems()
. That array seems to contain only file fields.
<cfset Local.filesArray = FORM.getFileItems() />
<cfloop array="#Local.filesArray#" index="local.currFile">
<cfset fileExt = ListLast(local.currFile.getName(), ".")>
</cfloop>
What is the purpose of the original code? As the file was already uploaded to the server, you could also move it to a safe directory with <cffile action="upload">
and check cffile.serverFileExt
instead.