jcesarmobile jcesarmobile - 1 year ago 161
Android Question

HTML file input in android webview (android 4.4, kitkat)

I was using the

<input type="file">
on the android webview.
I got it working thanks to this thread:
File Upload in WebView

But the accepted answer (or any other) no longer works with android 4.4 kitkat webview.

Anybody knows how to fix it?

It doesn't work with target 18 either.

I've looking some android 4.4 source code and it seems that the WebChromeClient hasn't changed, but I think the
no longer works on the kitkat webview, or at least not the

Answer Source

Update 2: There is a simpler plugin to use with phonegap/cordova


Update: Sample project with Cesidio DiBenedetto plugin


I opened an issue on the android open source project and the answer was:

Status: WorkingAsIntended

unfortunately, openFileChooser is not a public API. We are working on a public API in future releases of Android.

For those using phonegap/cordova, this workaround was posted on the bug tracker:

Cesidio DiBenedetto added a comment - 28/Mar/14 01:27

Hey all, I've been experiencing this issue as well so I wrote a Cordova FileChooser plugin to a "band-aid" for the time being. Basically, in Android 4.4(KitKat), as mentioned in previous comments, the file dialog is not opened. However the onclick event is still fired on so you can call the FileChooser plugin to open a file dialog and upon selection, you can set a variable that contains the full path to the file. At this point, you can use the FileTransfer plugin to upload to your server and hook into the onprogress event to show progress. This plugin is mainly configured for Android 4.4 so I would recommend to continue to use the native file dialogs for earlier versions of Android. There might be issues with the plugin as I have not fully tested all possible scenarios on many devices, but I have installed it on a Nexus 5 and it worked fine.


Not tested it because I built my own workaround

A comment form a chromium developer

We will be a adding a public API to WebViewClient in next major release to handle file requests.

It seems they consider it as a bug now and they are going to fix it

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download