I'm trying to create a fileupload. My file input:
<input class="form-control" name="file" type="file" size="20" accept="application/pdf, image/jpeg, image/png, text/plain" multiple >
And this method returns, the selected files and a additional element with size 1 and content type null
. This cause an errror.
for (Part part : request.getParts()) {
System.out.println("Dateigrösse: " + part.getSize());
uploadSize = uploadSize + part.getSize();
System.out.println("Dateityp: " + part.getContentType());
if(part.getContentType().equals("application/pdf") || part.getContentType().equals("text/plain") || part.getContentType().equals("image/jpeg") || part.getContentType().equals("image/png")) {
} else {
types = false;
}
}
First it worked, but know there's this null element. What should I do? Where does it comes from?
Thank you in advance.
Aucun commentaire:
Enregistrer un commentaire