Sudarsono Sung
Sudarsono Sung

Reputation: 83

Using FORM.getPartsArray() in Lucee

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>

Upvotes: 1

Views: 377

Answers (2)

SOS
SOS

Reputation: 6560

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.

Upvotes: 1

Alex Baban
Alex Baban

Reputation: 11742

Not exactly.

FORM.getPartsArray() is proprietary to Adobe, in Lucee you can try FORM.getRaw() but you'll probably have to do some work.

getName() will match but I'm not sure about the other ones.

Upvotes: 1

Related Questions