I am trying to put the filename of a failed upload into an email, inside a try / catch, but I am not having any luck.
Based on this documentation - FileUploadAll() - I decided I am going to use error.
<cftry>
<cffile destination="#FULLPATH#" action="upload" nameconflict="ERROR" continueOnError="true" filefield="FileName" />
<cfcatch type="Any" >
<cf_EmailHandler from="testmail@gmail.com" to="testmail@gmail.com" subject="Attachment Error - #BUILD_SEARCH.PROJECT_VERSION# #BUILD_SEARCH.BUILD_NUMBER#">
<CFOUTPUT>
Attachment Error - #BUILD_SEARCH.PROJECT_VERSION# #BUILD_SEARCH.BUILD_NUMBER#
Cannot upload the following file:
#FULLPATH# #ArrayLen(cffile.uploadAllErrors)#
</CFOUTPUT>
</cf_EmailHandler>
<b>Error:</b>File already exists.
<cfabort>
</cfcatch>
</cftry>
I get the following error:
Element UPLOADALLERRORS is undefined in CFFILE
So I try to fix that:
<cftry>
<cffile destination="#FULLPATH#" action="upload" nameconflict="ERROR" Errors="errorResult" continueOnError="true" filefield="FileName" />
<cfcatch type="Any" >
<cf_EmailHandler from="testmail@gmail.com" to="testmail@gmail.com" subject="Attachment Error - #BUILD_SEARCH.PROJECT_VERSION# #BUILD_SEARCH.BUILD_NUMBER#">
<CFOUTPUT>
Attachment Error - #BUILD_SEARCH.PROJECT_VERSION# #BUILD_SEARCH.BUILD_NUMBER#
Cannot upload the following file:
#FULLPATH# #ArrayLen(errorResult.uploadAllErrors)#
</CFOUTPUT>
</cf_EmailHandler>
<b>Error:</b>File already exists.
<cfabort>
</cfcatch>
</cftry>
Then I am getting:
Element UPLOADALLERRORS is undefined in ERRORRESULT.
Any idea on what I am doing wrong or another way to display the name of failed upload? Also I am using ColdFusion 11.