title: Phonegap and Jquery to get a Photo stored on the device and convert it to a base64 string, path is from the sqlite database
body: <p>I am having some problems converting the image into a base64 string to transmit over the xml. I stored the Image location(full path) into the database when I took the photo and I'm trying to upload it now. I am trying to Read the file that I have in the(results.rows.item(i).PictureFile) and then convert that to base64. Below is the part of the code im using to do this. Anything anyone can do to help would be great. </p>
  
  <pre><code>   function submitPhoto(PhotoId)
  {
      g_submitXML = '';
      var err = '';
      var errorsArr = $.makeArray(err);
      window.g_submitXML = '';
      window.g_submitXML = window.g_submitXML + '';
      window.g_submitXML = window.g_submitXML + '';
      window.g_submitXML = window.g_submitXML + '';
      console.log("successfully started the xml with: " + window.g_submitXML);
  
      var db = window.openDatabase("MobileData", "3.0", "MobilePhoneData", 1000000);
      db.transaction(function (tx) {
          tx.executeSql('SELECT * FROM MobilePhotos WHERE PhotoId = ' + PhotoId + '', 
            [], 
              function(tx, results) {
                  console.log("HIT THE RESULTS PHOTO FUNCTION");
                  var len = results.rows.length;
                  console.log("Photo table: " + len + " rows found.");
                   for (var i = 0; i &lt; len; i++)
                      {
                       window.g_submitXML = window.g_submitXML + '&lt;EMBEDDED_FILE _Type="JPEG" _Name="Image_' + i + '"';
                       window.g_submitXML = window.g_submitXML + '_Extension=.jpg _EncodingType="Base64" _ImageOrientation="' + results.rows.item(i).PictureLocationDesc + '"&gt;';
                       window.g_submitXML = window.g_submitXML + '&lt;DOCUMENT&gt;';
                       var reader = new FileReader();
                   console.log(results.rows.item(i).PictureFile);
  //I am having problems with the line below
                       window.g_submitXML = window.g_submitXML + reader.readAsDataURL(fileSystem.root.getFile(results.rows.item(i).PictureFile));
  //I am having problems with the line above ^
                       window.g_submitXML = window.g_submitXML + '&lt;/DOCUMENT&gt;';
                       window.g_submitXML = window.g_submitXML + '&lt;/EMBEDDED_FILE&gt;';
                      }
          }, 
          console.log("ERROR"));
  });
  
  
  }
  </code></pre>
  
  <p>Ive commented above and below the line I'm having issues with. </p>
  
  <p>Thanks! </p>