I'm trying to upload multiple files.
My template:
#{form @Application.upload(), enctype:'multipart/form-data'}
<input type="file" name="files"><br/>
<input type="file" name="files"><br/>
<input type="file" name="files"><br/>
<input type="submit" value="Upload" />
#{/form}
My controller method:
public static void upload( File[] files ) {
for ( int i=0; i<files.length; i++ ) {
File file = files[i];
if (null == file) continue;
System.out.println( "Absoluter Pfad: " + file.getAbsoluteFile() );
}
String text = params.get( "textfield" );
System.out.println("text: "+ text);
}
It works fine when there are three files to upload.
The problem is that i get a nullpointer when any field is left empty
and i send the form.
Any ideas?