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

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

https://github.com/MaginSoft/MFileChooser

Update:
Sample project with Cesidio DiBenedetto plugin

https://github.com/jcesarmobile/FileBrowserAndroidTest

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.

https://github.com/cdibened/filechooser

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

Leave a Comment