title: AngularJS: upload and post photo as multi-part form data and get response
body: <p>I want to upload an image and post it to my server which should post the image further on to some API and get its response.</p>
  
  <p>I could probably use view with something like:</p>
  
  <pre><code>&lt;form ng-submit="updatePhoto(myphoto)"&gt; 
      &lt;p&gt;Choose Photo:&lt;/p&gt;
      &lt;input type="file" ng-model="myphoto"&gt;
      &lt;input type="submit" value="Send"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and then in the controller the function would have something like:</p>
  
  <pre><code>$http({
          method: 'POST',
          url: 'myAPIserver.php/',
          data: "myPhoto=" + photo,
          headers: {'Content-Type': 'multipart/form-data'}
  });
  </code></pre>
  
  <p>But this is not correct and I am not sure how to accomplish this. The catch is that I am sending this photo to my PHP proxy first and from there I use curl to make direct API requests.</p>
  
  <p>I hope I was clear enough. Any suggestions appreciated, thanks</p>