i am sending both files and other fields data to servlet using ajax FormData append() as follows:
html
<form   id="formId1" >
   <input type="file" name="file" id="fileid">
   <input type="text" name="t1" id="d">
   <input type="submit" id="btn" value="submit">
</form>
ajax call:
  $("#btn").click(function(event){ 
                  event.preventDefault(); 
                  var fd = new FormData();
      var other_data = $('form').serializeArray();
                    $.each(other_data,function(key,input){
                        fd.append("t1",$("#d").val());
                      fd.append("file",$('#fileid').prop('files')[0])
                    });
                    $.ajax({
                        url: 'Sample1',
                        data: fd,
                        contentType: false,
                        processData: false,
                        type: 'POST',
                        success: function(data){
                            console.log(data);
                        }
                    });     });
and i used @MultipartConfig to read both files and other data
@WebServlet("/Sample1")
@MultipartConfig
public class Sample1 extends HttpServlet {
    private static final long serialVersionUID = 1L;
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    { 
        String s=request.getParameter("t1");
        System.out.println(s); 
        Part part=request.getPart("file");
        File path =new File("path")// HOW TO PUT PART INTO THE FOLDER
        }}
now am not able to store that part as image into the folder
how to get folder or images from Part please help me this.
