I need an input type=file web form element to open the file browser and return to the code with the selected file to be submitted. I accomplished this in a standard web form and tested in Android's regular browser, but when I wrap the app with Phonegap the button no longer works.What is the workaround for this? It seems like a lot of people are passing around an example where the camera is used, but I don't need the camera, I need a file browser.Thanks in advance!!Mike
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d("result code: ", " " + resultCode);
Uri uri = data.getData();
String[] proj = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(uri, proj, null, null, null);
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
Log.d("Complete File Path ", "" + cursor.getString(column_index));
Intent sharePageIntent = new Intent(this, ShareActivity.class);
sharePageIntent.putExtra(FILE_PATH, cursor.getString(column_index));
startActivity(sharePageIntent);
super.onActivityResult(requestCode, resultCode, data);
}
<html>
<head>
<title>File Upload Test Form</title>
<script language="JavaScript" src="../js/lib/jquery-1.7.1.min.js"></script>
</head>
<body onload="init()">
test page for JavaScript / Phonegap connectivity
<p></p>
<form method="POST" enctype="multipart/form-data" action="http://path/to/script/uploads.php">
File to upload: <input type="file" name="upload">
<input type="submit" value="Press to Upload..."> to upload the file!
</form>
</body>
</html>
Further clarification: the solution above is for Android 3.x and above. It needs to be in DroidGap, IMO.
Using ICS, I'm seeing the file name only in the input tag. Default browser.