title: How to upload file with additional information in java
body: <p>I am using apache <code>commons-fileupload</code> to upload file. But, I'm unable to pass more information about the attachment. For example, users want to add attachment information while uploading the particular file. So I send the comments together with attachment. But use commons-fileupload, I only get the attachment, but I can not get the comments. The code below is the form</p>
  
  <pre><code>&lt;form action"taskcontroller" method="post"  enctype="multipart/form-data"&gt;
          &lt;label for="filename_1"&gt;File: &lt;/label&gt;
          &lt;input id="filename_1" type="file" name="filename_1" size="50"/&gt;&lt;br/&gt;
          comments:&lt;input type='text' name='comments' /&gt;
          &lt;input type="submit" value="upload" name="command" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and the code below is to process the request,</p>
  
  <pre><code>boolean isMultipart = ServletFileUpload.isMultipartContent(request);  
  if (isMultipart) {  
      FileItemFactory factory = new DiskFileItemFactory();  
      ServletFileUpload upload = new ServletFileUpload(factory);  
      List&lt;FileItem&gt; items = upload.parseRequest(request);  
      Iterator iterator = items.iterator();  
      while (iterator.hasNext()) {  
          FileItem item = (FileItem) iterator.next();  
  
          if (!item.isFormField()) { //ignore the form element  
              String fileName = item.getName();  
              // TODO filesize int is it ok?  
              int size = (int) item.getSize();  
              String root = "";//Set the root  
              File path = new File(root + "/uploads");  
              if (!path.exists()) {  
                  boolean status = path.mkdirs();  
              }  
  
              item.write(uploadedFile); //write file to disk  
          }  
      }  
  }
  </code></pre>
  
  <p>but i can not get comments information...  </p>