title: Different image path for capture and upload option using cordova , android app
body: <p>I am working on an android app. There is an option to take pic to capture image using camera , and choose existing to take image from mobile. But when i try to get the path to pass to server, its showing different location </p>
  
  <p><strong>capture image</strong> : here i am getting exact path or fullPath like <code>file:///storage/sdcard0/DCIM/Camera/13212343.jpg</code></p>
  
  <p><strong>Choose existing</strong> : here i am getting uri like <code>content://media/external/images/media/4572</code></p>
  
  <p>So Is it possible to send this path to server ? If I send Like this , Java Program can identify this file ? Please help me. I want to send 2 parameters with image to backend.</p>
  
  <pre><code>uploadSubmit() This is the function for send to servlet.
  </code></pre>
  
  <p><strong>my code</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Ran Sample Testing&lt;/title&gt;
      &lt;script type="text/javascript" charset="utf-8" src="cordova.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="js/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="js/script.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          //js
  
      var pictureSource;   // picture source
      var destinationType; // sets the format of returned value 
  
      // Wait for Cordova to connect with the device
      document.addEventListener("deviceready",onDeviceReady,false);
  
      // Cordova is ready to be used!
      function onDeviceReady() {
          pictureSource=navigator.camera.PictureSourceType;
          destinationType=navigator.camera.DestinationType;
          document.addEventListener("backbutton", onBackKeyDown, false);
      }
  
      // Called when a photo is successfully retrieved
      function onPhotoURISuccess(imageURI) {
          // Get image handle
          var largeImage = document.getElementById('largeImage');
  
          // Unhide image elements
          document.getElementById("section3_part1").style.display= 'none';
          document.getElementById("section3_part2").style.display='block';
          largeImage.style.display = 'block';
  
          // Show the captured photo ...  The inline CSS rules are used to resize the image
          largeImage.src = imageURI;
          xyz = imageURI;
      }
  
      // A button will call this function
      function capturePhoto() {
          // Take picture using device camera and retrieve image as base64-encoded string
          navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50, saveToPhotoAlbum: true,
          destinationType: destinationType.FILE_URI });
      }
  
      // A button will call this function
      function getPhoto(source) {
          // Retrieve image file location from specified source
          navigator.camera.getPicture(onSuccessFun, onFail, { quality: 50, 
          destinationType: destinationType.FILE_URI,
          sourceType: source });
  
      }
  
      // Called if something bad happens.
      function onFail(message) {
          alert('back to home: ' + message);
      }
  
      function uploadSubmit(){
          var uploadingImage = document.getElementById('largeImage');
          var imgUrl = uploadingImage.src;
  
          //alert("upload submition started third"+ FILE_URI);
          options = new FileUploadOptions();
  
          // parameter name of file:
          options.fileKey = "my_image";
  
          // name of the file:
          options.fileName = imgUrl.substr(imgUrl.lastIndexOf('/') + 1);
  
          // mime type:
          options.mimeType = "image/jpeg";
          params = { val1: "some value", val2: "some other value" };
          options.params = params;
          ft = new FileTransfer();
          ft.upload(imgUrl, "http://externalurl.com/uploadServlet", success, fail, options);
      }
  
      function success(message) {
          alert("Your photo uploaded successfully.");
      }
      function fail(message) {
          alert("Failed because: " + message);
      }
  
  
  //ready function starts
  
  $( document ).ready(function() {
      $('#section1').animate({ "top": "0px" }, 300);
  
  //image rotaion
      var rotation = 0;
      jQuery.fn.rotate = function(degrees) {
      $('#largeImage').css({'-webkit-transform' : 'rotate('+ degrees +'deg)',
                   '-moz-transform' : 'rotate('+ degrees +'deg)',
                   '-ms-transform' : 'rotate('+ degrees +'deg)',
                   'transform' : 'rotate('+ degrees +'deg)'});
      var autoHgt = $('#largeImage').height;
      $(' .imageBox').css({"height": autoHgt});
      };
      $('.leftRotation').click(function() {
          rotation -= 90;
          $('#largeImage').rotate(rotation);
      });
      $('.rightRotation').click(function() {
          rotation += 90;
          $('#largeImage').rotate(rotation);
      });
  
  
  // section 2 popup
      $("#section2_Popup").bind( "click", function() {
          $('#section1').animate({ "top": "-999px" }, 300);
          $('#section2').animate({ "top": "0px" }, 300);
          $('#section3').animate({ "top": "-999px" }, 300);
          $('#section4').animate({ "top": "-999px" }, 300);
          $("#section1").css({"display":"none"});
          $("#section2").css({"display":"block"});
          $("#section3").css({"display":"none"});
          $("#section4").css({"display":"none"});
      });
  // section 3 part 1 popup
      $( "#section3_Popup" ).bind( "click", function() {
          var usrName = $("#inUserName").val();
          $('#section1').animate({ "top": "-999px" }, 300);
          $('#section2').animate({ "top": "-999px" }, 300);
          $('#section3').animate({ "top": "0px" }, 300);
          $('#section4').animate({ "top": "-999px" }, 300);
          $("#section1").css({"display":"none"});
          $("#section2").css({"display":"none"});
          $("#section3").css({"display":"block"});
          $("#section4").css({"display":"none"});
          displayName(usrName);
      });
  // section 3 part2 popup
      $( "#uploadImg" ).bind( "click", function() {
          $('#section1').animate({ "top": "-999px" }, 300);
          $('#section2').animate({ "top": "-999px" }, 300);
          $('#section3').animate({ "top": "-999px" }, 300);
          $('#section4').animate({ "top": "0px" }, 300);
          $("#section1").css({"display":"none"});
          $("#section2").css({"display":"none"});
          $("#section3").css({"display":"none"});
          $("#section4").css({"display":"block"});
          $("#section3_part1").css({"display":"block"});
          $("#section3_part2").css({"display":"none"});
      });
  
      // section 3 part2 popup cancel
      $( "#cancelUpload" ).bind( "click", function() {
          $('#section1').animate({ "top": "-999px" }, 300);
          $('#section2').animate({ "top": "-999px" }, 300);
          $('#section3').animate({ "top": "0px" }, 300);
          $('#section4').animate({ "top": "-999px" }, 300);
          $("#section1").css({"display":"none"});
          $("#section2").css({"display":"none"});
          $("#section3").css({"display":"block"});
          $("#section4").css({"display":"none"});
          $("#section3_part1").css({"display":"block"});
          $("#section3_part2").css({"display":"none"});
      });
  
      //back button 
      $( "#backBtn" ).bind( "click", function() {
          $('#section1').animate({ "top": "-999px" }, 300);
          $('#section2').animate({ "top": "-999px" }, 300);
          $('#section3').animate({ "top": "0px" }, 300);
          $('#section4').animate({ "top": "-999px" }, 300);
          $("#section1").css({"display":"none"});
          $("#section2").css({"display":"none"});
          $("#section3").css({"display":"block"});
          $("#section4").css({"display":"none"});
          $("#section3_part1").css({"display":"block"});
          $("#section3_part2").css({"display":"none"});
      });
  
      // name display
      function displayName(userName){
          var element=document.getElementById("user_name");
          element.innerHTML="Welcome "+userName;
          var element=document.getElementById("hiddenname");
          element.value=userName;
      }
  
      // input box image from library
  
      function readURL(input) {
          if (input.files &amp;&amp; input.files[0]) {
              var reader = new FileReader();
              reader.onload = function (e) {
                  $('#largeImage').attr('src', e.target.result);
                  $('#section3_part1').css({'display':'none'});
                  $('#section3_part2').css({'display':'block'});
                  $('#largeImage').css({'display':'block'});
              }
             // reader.readAsDataURL(input.files[0]);
          }
      }
      $("#inputFile").change(function(){
          readURL(this);
      });
  
   });
      &lt;/script&gt;
      &lt;style type="text/css"&gt;
          .wrapper{
              position: relative;
          }
          #section2, #section3, #section4, #section3_part2{
              display: none;
          }
          #section1, #section2, #section3, #section4{
              position: absolute;
              top: -999px;
              width: 100%;
          }
          #largeImage{
              display:none; 
              width:100%;
              height:auto;
          }
          .imageBox{
              width:80%;
              height:auto;
              margin: 0 auto;
              overflow: hidden;
          }
      &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div class="wrapper"&gt;
      &lt;div id="section1"&gt;
          &lt;span id="section2_Popup"&gt;START&lt;/span&gt;
      &lt;/div&gt;
      &lt;div id="section2"&gt;
          Enter Name:  &lt;input type="text" id="inUserName" placeholder="Enter your Name" required min="3"/&gt; &lt;button id="section3_Popup"&gt;Go&lt;/button&gt;
      &lt;/div&gt;
      &lt;div id="section3"&gt;
          &lt;div id="section3_part1"&gt;
              &lt;button onclick="capturePhoto();"&gt;Capture Photo&lt;/button&gt;&lt;br&gt;
              &lt;!-- &lt;button onclick="capturePhotoEdit();"&gt;Capture Editable Photo&lt;/button&gt; &lt;br&gt; --&gt;
              &lt;button onclick="getPhoto(pictureSource.PHOTOLIBRARY);"&gt;From Photo Library&lt;/button&gt;&lt;br&gt; 
              &lt;button onclick="getPhoto(pictureSource.SAVEDPHOTOALBUM);"&gt;From Photo Album&lt;/button&gt;&lt;br&gt;
              &lt;input type="file" name="From Mobile" id="inputFile"/&gt;
          &lt;/div&gt;
          &lt;div id="section3_part2"&gt;
              &lt;div class="imageBox"&gt;
                  &lt;img id="largeImage" src="index.png" /&gt;
              &lt;/div&gt;
              &lt;span class="leftRotation"&gt;left&lt;/span&gt; &lt;span class="rightRotation"&gt;right&lt;/span&gt;
              &lt;button id="uploadImg"&gt;Upload&lt;/button&gt;
              &lt;button id="cancelUpload"&gt;cancel&lt;/button&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div id="section4"&gt;
          &lt;div id="user_name"&gt;&lt;/div&gt;
          &lt;input type="hidden" id="hiddenname" /&gt;
          Email id* : &lt;input type="text" id="emailid" placeholder="Enter Email id" /&gt;&lt;br/&gt;
          Phone* : &lt;input type="text" id="phone" placeholder="Enter your phone number" /&gt;&lt;br/&gt;
          Caption (optional) : &lt;input type="text" id="captn" placeholder="Enter a caption" /&gt;&lt;br/&gt;
          &lt;button id="submitBtn" onClick="uploadSubmit()"&gt;SUBMIT&lt;/button&gt;
          &lt;button id="backBtn"&gt;BACK&lt;/button&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>