title: How to upload FormData object using AngularJS
body: <p>I am new to angular-js, and wants to submit the multipart/form-data with an image and it's $http.post() method supports only json format, so I want to convert formdata object to the json format,</p>
  
  <pre><code>$scope.SubmitForm=function()
  {
      url = siteurl + '/admin/' + $scope.module + '/add';
  
      var form=document.getElementById("addForm");
      var formData=new FormData(form);
  
      $http({
          url     :   url,
          method  :   "POST",
          data    :   formData,
      })
      .then(function(responseText) {                
          alert(JSON.stringify(responseText));
  
      //process data
      },function(){
          alert("hello from error");
      });
  
  } 
  </code></pre>
  
  <p>it didnot work for me; and i tried to make json format data for this and works fine</p>
  
  <pre><code>formData={
      "first_name" :  $('#first_name').val(),
      "last_name"  :  $('#last_name'),
      //....
  };
  </code></pre>
  
  <p>but don't have any idea to append my image file to this format; what should i do right here to get my job.</p>
  
  <p>Is there any way(function) to convert formdata object to json format</p>