title: How to make Phonegap's (Cordova) File API work like File API in normal browser
body: <p>Is there a way to make Phonegap's File API work just like same API works in browser?
  I need same behavior as in browser: Tap on "Open file" button -> "Select File" dialog ->... -> Opening the file with FileReader Object.</p>
  
  <p>Thank you!!!</p>
  
  <p><strong>UPDATE:</strong> I've found some solution. It opens File Dialog and it returns the name of the JS File Object. But when i pass that JS File Object to FileReader from PhoneGap - it doesn't open (onload listener never fires). What i do wrong?</p>
  
  <p>Here's my Java:</p>
  
  <pre><code>package org.apache.cordova.example;
  
  import android.os.Bundle;
  import org.apache.cordova.api.CordovaInterface;
  import android.content.Intent;
  import android.net.Uri;
  import android.webkit.ValueCallback;
  import org.apache.cordova.CordovaChromeClient;
  import org.apache.cordova.CordovaWebView;
  import org.apache.cordova.DroidGap;
  
  
  public class cordovaExample extends DroidGap
  {
  private ValueCallback&lt;Uri&gt; mUploadMessage;
  private final static int FILECHOOSER_RESULTCODE = 1;
  
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      super.loadUrl("file:///android_asset/www/index.html");
  
      this.appView.setWebChromeClient(new FileAttachmentChromeClient(this,     this.appView));
  }
  
  
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
      if (requestCode == FILECHOOSER_RESULTCODE) {
          if (null == mUploadMessage) return;
          Uri result = intent == null || resultCode != RESULT_OK ? null : intent.getData();
          mUploadMessage.onReceiveValue(result);
          mUploadMessage = null;
      }
  }
  
  // openFileChooser is an overridable method in WebChromeClient which isn't
  // included in the SDK's Android stub code
  public class FileAttachmentChromeClient extends CordovaChromeClient {
  
      public FileAttachmentChromeClient(CordovaInterface ctx, CordovaWebView app) {
          super(ctx, app);
  
      }
      public void openFileChooser(ValueCallback&lt;Uri&gt; uploadMsg) {
          mUploadMessage = uploadMsg;
          Intent i = new Intent(Intent.ACTION_GET_CONTENT);
          i.addCategory(Intent.CATEGORY_OPENABLE);
          i.setType("*/*");
          cordovaExample.this.startActivityForResult(Intent.createChooser(i, "Choose type of attachment"), FILECHOOSER_RESULTCODE);
      }
  
  }
  }
  </code></pre>
  
  <p>And what i do with JavaScript:</p>
  
  <pre><code> var SelectedFile;
   var FReader; 
  
   document.getElementById('fileBox').addEventListener('change', fileChosen);     
  
  
   function fileChosen(evnt) {
  SelectedFile = evnt.target.files[0];      
       FReader = new FileReader(); 
       FReader.readAsDataURL(SelectedFile);
       FReader.onload = function(loadevnt){   ....   }  //never happens
  }
  </code></pre>