0

I'm going crazy to fix input type="file" in static webview. I create a simple webapp in html+js and i'm trying with Android Studio to build a simple webview that load my website url. This is code:

public class MainActivity extends Activity {

private WebView MyWeb;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    MyWeb =(WebView) findViewById(R.id.webView);
    MyWeb.getSettings().setJavaScriptEnabled(true);
    MyWeb.getSettings().setSaveFormData(true);

    MyWeb.loadUrl("http://phpfileuploader.com/demo/ajax-multiplefiles.php");
    MyWeb.setWebViewClient(new WebViewClient());

}

public class myWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }
}

public void onBackPressed() {
    if (MyWeb.canGoBack()) {
        MyWeb.goBack();
    } else {
        super.onBackPressed();
    }
}

}

I see that all work except input file from html. Need that user upload file image with ext(.png, .jpg, .jpeg) for change their avatar. I read other solution on line about but nothing seems to work! Someone can help me?

zaGooX
  • 1
  • 3
  • Be a lot more specific about what isn't working, what you expect to happen and what isn't. And unless your problem is "nothing is loading in my webview" you'll probably need to give us your webpage code as well. – Gabe Sechan Mar 11 '15 at 22:36
  • no work when selected! Not open filechooser of android – zaGooX Mar 11 '15 at 22:38
  • if i use browser no problem filechooser work correctly but inside webview no work! – zaGooX Mar 11 '15 at 22:49
  • 1
    You need to `setWebChromeClient` and override `openFileChooser`. The solution is here. http://stackoverflow.com/questions/5907369/file-upload-in-webview/15423907#15423907 – nuuneoi Mar 11 '15 at 23:19
  • hi nuuneoi, that solution don't work! i try but nothing :( – zaGooX Mar 12 '15 at 08:07

0 Answers0