I want to open file upload when page loaded.I used this code but it not working.

<input type="file"  id="browse" style="visibility:hidden;"  
accept="image/*" capture="camera" />    

<input style="background-color: #008CBA; color:white;"  type="button" 
value="Scan BarCode" id="fakeBrowse" />

   <script>
    window.onload=function(){
     $('#browse').trigger("click");
    }; 
    </script>

Please guide me how it will work.Thanks

1 Answers

0
Atchutha rama reddy Karri On

Try this

<html>
  <body>
    <input type="file" style="display: none" />
    <button>Open File Dialog</button>
    <script src="https://code.jquery.com/jquery-2.2.4.js"></script>
    <script>
      $("button").on("click", function() {
        $("input").trigger("click");
      });
    </script>
  </body>
</html>