private String[] extractDispositionInfo(String line) throws IOException
   {
      // Return the line's data as an array: disposition, name, filename
      String[] retval = new String[4];

      // Convert the line to a lowercase string without the ending \r\n
      // Keep the original line for error messages and for variable names.
      String origline = line;
      line = origline.toLowerCase();

      // Get the content disposition, should be "form-data"
      int start = line.indexOf("content-disposition: ");
      int end = line.indexOf(";");
      if (start == -1 || end == -1) throw new IOException("Content disposition corrupt: " + origline);
      String disposition = line.substring(start + 21, end);
      if (!disposition.equals("form-data")) throw new IOException("Invalid content disposition: " + disposition);

      // Get the field name
      start = line.indexOf("name=\"", end);  // start at last semicolon
      end = line.indexOf("\"", start + 7);   // skip name=\"
      if (start == -1 || end == -1) throw new IOException("Content disposition corrupt: " + origline);
      String name = origline.substring(start + 6, end);

      // Get the filename, if given
      String filename = null;
      String origname = null;
      start = line.indexOf("filename=\"", end + 2);  // start after name
      end = line.indexOf("\"", start + 10);          // skip filename=\"
      if (start != -1 && end != -1)
      {                // note the !=
         filename = origline.substring(start + 10, end);
         origname = filename;
         // The filename may contain a full path.  Cut to just the filename.
         int slash = Math.max(filename.lastIndexOf('/'), filename.lastIndexOf('\\'));
         if (slash > -1) filename = filename.substring(slash + 1);  // past last slash
      }

      // Return a String array: disposition, name, filename
      // empty filename denotes no file posted!
      retval[0] = disposition;
      retval[1] = name;
      retval[2] = filename;
      retval[3] = origname;
      return retval;
   }