I'm trying to get the request parameters that are sent by a form enctype "multipart/form-data". I am using apache commons fileupload.
My code is below.
FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); List items = upload.parseRequest(req); Iterator uploadIterator = items.iterator(); while(uploadIterator.hasNext()){ FileItem uploadedItem = (FileItem) uploadIterator.next(); if (uploadedItem.isFormField()){ if (uploadedItem.getFieldName().equals("name")){ name = uploadedItem.getString(); } }else{ //Uploaded files comes here } The HTML code of the form is:
<form name="form" id="form" method="post" action="ServletIncluirEvento" enctype="multipart/form-data"> ... //Here comes a lot of inputs (I changed the name of the attribute because I am from Brazil and the names are in portuguese) <select size="9" id="idOpcoesSelecionadas" name="opcoesSelecionadas" multiple style="width: 100%;"> <% it = colecaoUsuarioSelecionado.iterator(); String name= ""; while (it.hasNext()) { usuario = (Usuario) it.next(); name += usuario.getName() + "/"; %> <option value="<%=usuario.getLogin()%>"> <%=usuario.getName()%> </option> <% } %></select> <input type="hidden" value="<%=name%>" name="name" /> Even so the parameter is coming null.
Someone knows how to solve?
Thank you in advance