Is there a way of making a flutter webview use android camera for file upload? How to open file picker in webview_flutter flutter?

5,733

I think this is an alternative solution using "webview_flutter" : https://github.com/flutter/flutter/issues/27924#issuecomment-647197754

Have to edit "FlutterWebView.java" and "AndroidManifest".

Share:
5,733
Admin
Author by

Admin

Updated on December 17, 2022

Comments

  • Admin
    Admin over 1 year

    I have a flutter web application with a webview that loads my PHP project from a server. In my PHP project, I have a registration form that requires a user to capture photos using the camera then upload it to the MySQL DB. The problem is that when I click the upload file button to use the camera it does nothing. But in the browser, the file chooser is working but on my android from the webview it's not doing anything.

    I tried this it's not working as well.

    <div class="col-sm-4">
    Image 1 <span style="color:red">*</span><input type="file" name="img1" accept"image/*" capture="camera"  required>
    </div>
    

    Here are my imports too.

    import 'package:car_renting_app/Animations/FadeAnimation.dart';
    import 'package:car_renting_app/onboarding.dart';
    import 'package:car_renting_app/popup.dart';
    import 'package:car_renting_app/ui/adminwebview.dart';
    import 'package:car_renting_app/widgets/animated_botton_bar.dart';
    import 'package:flutter/cupertino.dart';
    import 'package:flutter/gestures.dart';
    import 'package:flutter/material.dart';
    import 'package:flutter/services.dart';
    import 'package:url_launcher/url_launcher.dart';
    import 'package:webview_flutter/webview_flutter.dart';
    import 'package:connectivity/connectivity.dart';
    

    Here is my pubsec.yaml

    cupertino_icons: ^0.1.2
    webview_flutter:
    simple_animations: ^1.1.3
    page_transition: ^1.1.4
    carousel_pro: ^0.0.13
    url_launcher: ^5.1.1
    sliding_up_panel: ^0.3.4
    font_awesome_flutter: ^8.5.0
    flutter_swiper: ^1.1.6
    connectivity:
    uni_links: