title: PhoneGap upload Image to server on form submit
body: <p>I am facing problem here as in phonegap image is uploaded to the server once u select a picture.I don't want to upload image before submitting form. Image is uploaded automatically to server which is something i don't want.I want to upload image with the form, where form contains many more fields which is required to send along with image.  What are the possible ways to submit with form?  </p>
  
  <pre><code>&lt;!DOCTYPE HTML &gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Registration Form&lt;/title&gt;
  &lt;script type="text/javascript" charset="utf-8" src="phonegap-1.2.0.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" charset="utf-8"&gt;
  
      // Wait for PhoneGap to load
      document.addEventListener("deviceready", onDeviceReady, false);
  
      // PhoneGap is ready
      function onDeviceReady() {
  // Do cool things here...
      }
  
      function getImage() {
          // Retrieve image file location from specified source
          navigator.camera.getPicture(uploadPhoto, function(message) {
  alert('get picture failed');
  },{
  quality: 50,
  destinationType: navigator.camera.DestinationType.FILE_URI,
  sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
  });}
      function uploadPhoto(imageURI) {
          var options = new FileUploadOptions();
          options.fileKey="file";
          options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
          options.mimeType="image/jpeg";
  
          var params = new Object();
          params.value1 = "test";
          params.value2 = "param";
  
          options.params = params;
          options.chunkedMode = false;
  
          var ft = new FileTransfer();
          ft.upload(imageURI, "http://yourdomain.com/upload.php", win, fail, options);
      }
  
      function win(r) {
          console.log("Code = " + r.responseCode);
          console.log("Response = " + r.response);
          console.log("Sent = " + r.bytesSent);
          alert(r.response);
      }
  
      function fail(error) {
          alert("An error has occurred: Code = " = error.code);
      }
  
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form id="regform"&gt;
  &lt;button onclick="getImage();"&gt;select Avatar&lt;button&gt;
  &lt;input type="text" id="firstname" name="firstname" /&gt;
  &lt;input type="text" id="lastname" name="lastname" /&gt;
  &lt;input type="text" id="workPlace" name="workPlace" class="" /&gt;
  &lt;input type="submit" id="btnSubmit" value="Submit" /&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>