Press enter to see results or esc to cancel.


recaptcha to download a file HTML

This tutorial shows how to integrate reCaptcha for download a file. This is HTML example and will work for all programming languages.

 

Please note that this example will run in server after updating the site information in recaptcha site as shown in the youtube video.

  1. First get the site key from google recaptcha site. Please visit the below link for detailed step by step process for that.
    http://chillyfacts.com/add-recaptcha-i-m-not-a-robot-in-java-websites/

    
    
  2. test.html
    <!DOCTYPE html>
    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
    <script>
    $(document).ready(function(){
     $("form").submit(function(){
       var response = grecaptcha.getResponse();
          if(response.length == 0){
              alert('Please check the Captcha');
        return false;
     } 
     });
    });
    </script>
     <script type="text/javascript">
     var onloadCallback = function() {
     grecaptcha.render('html_element', {
     'sitekey' : 'UPDATE YOUR SITE KEY HERE'
     });
     };
     </script>
    </head>
    <body>
    <h3>Click to download the file</h3>
       <form action="http://mykuttywap.in/2013-mp3/dl/load/Malayalam%20Mp3/Malayalam%20(2015)/Maalgudi%20Days/Nepredskazuuye%20Maa.mp3" method="post">
       <div id="html_element"></div>
           <br>
           <input type="submit" value="Download">
       </form> 
     <script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"
     async defer>
     </script>
    </body>
    </html>
  3. http://localhost:8080/Test_Rec/test.html
    
    

Comments

Leave a Comment