title: Cordova/phonegap: Take a photo and send it to my server
body: <p>at the moment, in my app, I have a screen where the user click on "send" and send some data to ther server (a wcf service).</p>
  
  <p>Now, I'd like to add a feature: in addition to the actual sent data, the user has to take a photo and send it with the other parameters.</p>
  
  <p>I have added the plugin (camera) and create the template.</p>
  
  <pre><code>function capturePhoto() {
      alert("1");
      navigator.camera.getPicture(onPhotoDataSuccess, onFail, {
          quality: 50,
          destinationType: navigator.camera.DestinationType.FILE_URI,
          //destinationType: navigator.camera.DestinationType.NATIVE_URI,
          //sourceType: sourceType.CAMERA
      });
  }
  
  function onPhotoDataSuccess(imageData) {
      alert("S");
      var smallImage = document.getElementById('myImage');
      smallImage.style.display = 'block';
      smallImage.src = "data:image/jpeg;base64," + imageData;
      image = "data:image/jpeg;base64," + imageData;
      alert("Image = " + image);
  }
  
  function onFail(message) {
      alert('Failed because: ' + message);
  }
  </code></pre>
  
  <p>I'm sure I have to manage something in the onSuccess function, but how can I reach my goal? After the picture is taken, I have to send it adding the picture as parameters here:</p>
  
  <pre><code>$.ajax({
      type: "POST",
      contentType: "application/json",
      dataType: "json",
      url: url,
      data: JSON.stringify({ "data": date_str, "PICTUREHERE":pictureHere }),
      success: function (output) {
            //my stuff
              },
      error: function (XMLHttpRequest, textStatus, errorThrown) {
            //my error stuff
  
       }
   });
  </code></pre>
  
  <p>My deviceReady function is:</p>
  
  <pre><code>$(document).on("deviceready", function () {
      navigator.splashscreen.hide();
  });
  </code></pre>
  
  <p>I think in server side the "pictureHere" parameter has to be a byte[], but I don't know how to manage the app side.</p>
  
  <p>UPDATE: my config.xml</p>
  
  <pre><code>&lt;widget id="com.devexpress.apptemplate" version="1.0" versionCode="1"&gt;
    &lt;name&gt;ApplicationTemplate&lt;/name&gt;
    &lt;description&gt;Template&lt;/description&gt;
    &lt;author email="info@info.com" href="http://www.info.com/"&gt;info&lt;/author&gt;
    &lt;preference name="permissions" value="none" /&gt;
    &lt;preference name="prerendered-icon" value="true" /&gt;
    &lt;preference name="android-windowSoftInputMode" value="adjustPan" /&gt;
    &lt;!--&lt;preference name="phonegap-version" value="cli-7.0.1" /&gt;--&gt;
  
    &lt;!--&lt;preference name="SplashScreen" value="splash" /&gt;--&gt;
    &lt;preference name="SplashScreenDelay" value="60000" /&gt;
    &lt;preference name="AutoHideSplashScreen" value="false" /&gt;
    &lt;preference name="SplashShowOnlyFirstTime" value="false" /&gt;
    &lt;preference name="FadeSplashScreen" value="false" /&gt;
    &lt;preference name="ShowSplashScreenSpinner" value="false" /&gt;
    &lt;preference name="DisallowOverscroll" value="true" /&gt;
    &lt;preference name="StatusBarOverlaysWebView" value="false" /&gt;
    &lt;preference name="StatusBarBackgroundColor" value="#000000" /&gt;
    &lt;preference name="android-minSdkVersion" value="14" /&gt;
    &lt;preference name="android-targetSdkVersion" value="22" /&gt;
    &lt;!--&lt;plugin name="cordova-plugin-file" /&gt;--&gt;
    &lt;!--&lt;plugin name="cordova-plugin-camera" /&gt;--&gt;
    &lt;plugin name="cordova-plugin-camera" spec="^2.4.1"&gt;
      &lt;variable name="CAMERA_USAGE_DESCRIPTION" value=" " /&gt;
      &lt;variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value=" " /&gt;
    &lt;/plugin&gt;
    &lt;plugin name="cordova-plugin-splashscreen" onload="true" /&gt;
    &lt;plugin name="cordova-plugin-whitelist" /&gt;
    &lt;plugin name="cordova-plugin-ios-longpress-fix" /&gt;
    &lt;plugin name="cordova-plugin-statusbar" onload="true" /&gt;
    &lt;access origin="*" /&gt;
  &lt;/widget&gt;
  </code></pre>
  
  <p>In my html page I added</p>
  
  <pre><code>&lt;img id="myImage" /&gt;
  </code></pre>