private static FormItem getFormItem ( PageContext pageContext , String filefield ) throws PageException { // check filefield if ( StringUtil . isEmpty ( filefield ) ) { FormItem [ ] items = getFormItems ( pageContext ) ; if ( ArrayUtil . isEmpty ( items ) ) throw new ApplicationException ( "no file send with this form" ) ; return items [ 0 ] ; } PageException pe = pageContext . formScope ( ) . getInitException ( ) ; if ( pe != null ) throw pe ; lucee . runtime . type . scope . Form upload = pageContext . formScope ( ) ; FormItem fileItem = upload . getUploadResource ( filefield ) ; if ( fileItem == null ) { FormItem [ ] items = upload . getFileItems ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < items . length ; i ++ ) { if ( i != 0 ) sb . append ( ", " ) ; sb . append ( items [ i ] . getFieldName ( ) ) ; } String add = "." ; if ( sb . length ( ) > 0 ) add = ", valid field names are [" + sb + "]." ; if ( pageContext . formScope ( ) . get ( filefield , null ) == null ) throw new ApplicationException ( "form field [" + filefield + "] is not a file field" + add ) ; throw new ApplicationException ( "form field [" + filefield + "] doesn't exist or has no content" + add ) ; } return fileItem ; }
rreturn fileItem matching to filefiled definition or throw a exception