title: file upload "multipart/form" Exception org.apache.commons.fileupload.FileUploadBase$InvalidContentTypeException
body: <p>I tried to use the file upload using Apache Commons but the following exception thrown</p>
  
  <p>org.apache.commons.fileupload.FileUploadBase$InvalidContentTypeException: the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is null</p>
  
  <p>My html code is</p>
  
  <pre><code>&lt;form  name="inp" action="upload.jsp"  method="get" onsubmit="return valid();" enctype="multipart/form-data"&gt;
  &lt;table align="center" cellspacing="2"&gt;
  
    &lt;tr&gt;&lt;td&gt;&lt;font size="5" color="#E41B17"&gt;Select File&lt;/font&gt; &lt;/td&gt;
  &lt;td&gt;&lt;input type="file" name="infile"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;&lt;font size="5" color="#E41B17"&gt;Target File Name&lt;/font&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" size="20" name="filename"&gt;&lt;/input&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td colspan="2" align="center"&gt;&lt;input type=submit value="Upload"  &gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  &lt;br&gt;&lt;/br&gt;
  &lt;center&gt;
  &lt;a href="index.html"&gt;&lt;font color="#E41B17"&gt;HOME&lt;/font&gt;&lt;/a&gt;
  &lt;/center&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>My JSP code is</p>
  
  <pre><code>   &lt;% 
     String user = (String)session.getAttribute("uname");
     String f = request.getParameter("filename");
  
     DiskFileUpload upload = new DiskFileUpload();         
     boolean isMultipart=upload.isMultipartContent(request);
  
  
     upload.setSizeMax(1048576);     
     List items = upload.parseRequest(request);  
     FileItem  file = (FileItem) items.get(0); 
  
     String source = file.getName();
        String delim="\\";
     String str="";
     File propfile=new File("C:\\eclipse_practise\\fileupload\\WebContent\\path.properties");
  
     BufferedInputStream propbuf=new BufferedInputStream(new FileInputStream(propfile));
  
     Properties path=new Properties();
  
     path.load(propbuf);
  
     String serverlocation=path.getProperty("Server_path");
  
     session.setAttribute("storelocation",serverlocation);
  
     StringTokenizer st = new StringTokenizer(source,delim);
  
     while(st.hasMoreTokens())
     {                        
         str=st.nextToken();
     }
  
     FileItem  name = (FileItem) items.get(1);
  
     String  target = name.getString();
  
     File outfile = new File(serverlocation+target);
  
      file.write(outfile); 
  
        session.setAttribute("filename",target);
  
     %&gt;
  </code></pre>