choose a file from device and upload it to page loaded in the webview
In the webview, one page from url is loaded. and in that page, a button for browse file is there in the name "choose file". When the user clicks the button, the app should show the gallery to select a file and retrieve it to that page as input. how c开发者_StackOverflow社区an i implement this?
To choose a file:
final int CHOOSE_FILE = 1;
//...
Intent chooseFile = new Intent(Intent.ACTION_GET_CONTENT);
chooseFile.setType("file/*");
Intent c = Intent.createChooser(chooseFile, "Choose file");
startActivityForResult(c, CHOOSE_FILE);
Then in your onActivityResult:
if(resultCode == RESULT_OK){
Uri uri = data.getData();
String filePath = uri.getPath();
// here goes the code to upload the file
}
精彩评论