title: how to receive canvas `toDataURL()` in java servlet?
body: <p>Somehow I am capturing a canvas image through camera and send it's <code>canvas.toDataURL()</code> to server so the server can save it as a png file, Now before I mention the problem here is my code:</p>
  
  <pre><code>var dataURL = canvas.toDataURL("image/png");
      formdata = dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
      alert(formdata);
      $.ajax({
          url: '../canvasdopost',
          type: 'POST',
          data: formdata,
          processData: false,
          contentType: false,
          success: function(data){
  
          }
      });
  </code></pre>
  
  <p>Server:</p>
  
  <pre><code>protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       Part part = request.getPart("canvasdata");
        BufferedReader br = new BufferedReader(new InputStreamReader(part.getInputStream(),
            Charset.forName("utf-8")));
        String sImg = br.readLine();
        System.out.print(sImg);
  }
  </code></pre>
  
  <p>Server console output:</p>
  
  <blockquote>
    <p>java.lang.IllegalStateException: Unable to process parts as no multi-part configuration has been provided
        at org.apache.catalina.connector.Request.parseParts(Request.java:2733)</p>
  </blockquote>
  
  <p>I also tried:</p>
  
  <pre><code>String test = request.getReader().lines().collect(Collectors.joining(System.lineSeparator()));
  System.out.print(test);
  </code></pre>
  
  <p>now the problem is that I never get my server console to output what I get in my client alert box before sending the data.</p>
  
  <p>And thanks for those too who tell me how to save the received base64 data to an actual image file</p>