title: Append image file to form data - Cordova/Angular
body: <p>I am using Anuglar, Ionic and Cordova in my current project, and I'm trying to POST FormData containing an image file to my server. Right now I'm using the <a href="https://github.com/apache/cordova-plugin-camera">cordova camera plugin</a> to return a file path to the image on the device (ex: file://path/to/img). Once I have the file path I want to append the image file to a FormData object using the images file path. Here is my code right now.</p>
  
  <pre><code>var fd = new FormData();
  
  fd.append('attachment', file);
  fd.append('uuid', uuid);
  fd.append('userRoleId', userRole);
  </code></pre>
  
  <p>The code above works when appending a file that is taken from an <code>&lt;input type='file'&gt;</code> but doesn't work when just given the file path on the device. </p>
  
  <p>Basically the FormData is showing like this right now: </p>
  
  <pre><code>------WebKitFormBoundaryasdf
  Content-Disposition: form-data; name="attachment"; 
  
  file://path/to/img
  </code></pre>
  
  <p>and I want it to look like this</p>
  
  <pre><code>------WebKitFormBoundaryasdf
  Content-Disposition: form-data; name="attachment"; filename="jesus-quintana.jpg"
  Content-Type: image/jpeg
  </code></pre>
  
  <p>I found many different ways to upload the image using cordova FileTransfer and by converting the image to a base64 and then uploading it. But I couldn't find any simple ways of just grabbing the file by using the path and posting it within a form. I'm not very familiar with the <a href="http://dev.w3.org/2009/dap/file-system/file-writer.html">File Api</a> so any help would be appreciated</p>