I'm modifying an application written by someone else. It uses the ColdFusion
<cffile action="uploadall"
How can I check and limit the size on an individual file basis when uploading multiple files?
I'm modifying an application written by someone else. It uses the ColdFusion
<cffile action="uploadall"
How can I check and limit the size on an individual file basis when uploading multiple files?
You will get the uploaded files' details in an Array. You can loop over them and do the file size validation logic independent from cffile
tag.
<cffile
action="uploadall"
destination="#GetTempDirectory()#"
nameconflict="MakeUnique"
result="fileUploaded"
>
<cfset invalidFiles = []>
<cfloop array="#fileUploaded#" item="item">
<cfif item.fileSize GT sizeLimitInMB*1024*1024>
<cfset arrayAppend(invalidFiles, {
'fileName': item.clientFile
})>
<!--- You can remove the file manually from here. --->
</cfif>
</cfloop>
<cfreturn invalidFiles> <!--- Or do anything your business logic require --->