how to use reCaptcha 2.0 in asp classic with multiple image uploader?

136 Views Asked by At

i am using asp classic in which i use recaptcha 2.0 when i used enctype="multipart/form-data" my image uploader work fine but recaptcha response is false and when i remove enctype="multipart/form-data" on form tag recaptcha work fine but not image uploader please help me

recaptcha method

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then Dim recaptcha_secret, sendstring, objXML

    ' Secret key
    recaptcha_secret = "secret key"

    sendstring = "https://www.google.com/recaptcha/api/siteverify?secret=" & recaptcha_secret & "&response=" & Request.form("g-recaptcha-response")

    Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")
    objXML.Open "GET", sendstring, False

    objXML.Send
Dim oJSON,jsonstring,result,data,success
    Set oJSON = New aspJSON

result = (objXML.responseText)

Set oJSON = New aspJSON
oJSON.loadJSON(result)

Set objXML = Nothing

success = oJSON.data("success")
if success = "True" then

    TestCaptcha ="True"
else
    TestCaptcha ="False"

end if     
    Set objXML = Nothing
End If
1

There are 1 best solutions below

0
AlexLaforge On

You cannot use Request.form("g-recaptcha-response") when posting a form with enctype="multipart/form-data", as the ``Request.Form`collection is not available.

Instead, use your Upload component DLL property (usually formtoo). For example, with the Persists ASPUpload component, use :

Set Uploader = Server.CreateObject("Persits.AspUpload")`
Dim myFormField
myFormField = Uploader.Form("g-recaptcha-response")

You can then use your variable myFormField to pass to Google ReCaptcha, like this :

sendstring = "https://www.google.com/recaptcha/api/siteverify?secret=" & recaptcha_secret & "&response=" & myFormField