title: Angularjs $http post file and form data
body: <p>I have the below request in python</p>
  
  <pre><code>import requests, json, io
  
  cookie = {}
  payload = {"Name":"abc"}
  url = "/test"
  file = "out/test.json"
  
  fi = {'file': ('file', open(file) )}
  r = requests.post("http://192.168.1.1:8080" + url, data=payload, files=fi, cookies=cookie)
  print(r.text)
  </code></pre>
  
  <p>which send a file, and form fields to the backend. How can I do the same (sending file + form fields) with Angular $http. Currently, I do like this, but not sure how to send the file too.</p>
  
  <pre><code>var payload = {"Name":"abc"};
  $http.post('/test', payload)
      .success(function (res) {
      //success
  });
  </code></pre>