title: PhoneGap File Upload to WCF
body: <p>How do I upload an image from the mobile device to my external database?</p>
  
  <p>Here is my current WCF Service:</p>
  
  <p>Interface: </p>
  
  <pre><code>[WebInvoke(UriTemplate = "/Upload", Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped), CorsEnabled]
  string UploadProfileImage(string image);
  </code></pre>
  
  <p>Class Method:</p>
  
  <pre><code>public string UploadProfileImage(string image)    
  { 
      // Upload code needs to go here. 
  }
  </code></pre>
  
  <p>I can post using ajax just fine, I'm just lost on how to do it with an image.</p>
  
  <p>Here is the jQuery example of how I do a post.</p>
  
  <pre><code>// This is the success function that gets called after selecting an image from my device
  function uploadSuccess(imageURI) {
      uploadImage(imageURI);
  }
  
  function uploadImage(imageURI)
  {
      var data = '{"image":"' + imageURI + '"}'
      $.ajax({
          url: "http://192.168.101.55:8848/api/Upload",
          type: "POST",
          contentType: "application/json",
          data: data,
          success: function (result) {
  
          },
          error: function (jqXHR, textStatus, errorThrown) {
  
          }
      });
  }
  </code></pre>