Posting a Base64 encoded file to a web server

K

Kevin

I'm using a MagTek check / credit card scanner to scan checks and then
submit the check data to NovaInfo through their viaWarp Gateway. The
NovaInfo people won't even return my emails, so I'm hoping someone
here can help me.

The scanner outputs the image in a base64 encoded text string. I'm
using the following code to POST the data:


web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")

Try
PostData = Encoding.ASCII.GetBytes(strData)
result = web.UploadData(URL, "POST", PostData)
Catch
ResultString = "Failure|No connection to the process server"
GoTo Exit_Function
End Try


URL is "http://SERVER:81/cgi-bin/ecs.cgi"

and strData is:
"UserID=__GATEWAYUSER__;__GATEWAY*USER__&ProfileName=CFFA&CheckData=O021108O
T062000080T 68 289
622O&Amount=350.00&StateCode=FL&UserDefined0=MCNESBY,
RON&CheckImage=SUkqALgAAABUQUdfMjY5X19fX19fX1gAVEFHXzI3MF9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19YAABNYWdUZWssIEluYy4AAE1JQ1JJbWFnZSBSUzIzMiAoQTAzWTRBVykAVmVyc2lvbiBNSTEuMDYuMjRKAABUQUdfMzA2X19fX19fX19fX19YAFRBR18zMTVfX19fWAAAyAAAAAEAAADIAAAAAQAAABUA/gADAAEAAAAAAAAAAAEDAAEAAAC8BgAAAQEDAAEAAAC8AgAAAwEDAAEAAAAEAAAABgEDAAEAAAAAAAAACgEDAAEAAAABAAAADQECABAAAAAIAAAADgECADEAAAAYAAAADwECAA0AAABKAAAAEAECABoAAABYAAAAEQEEAAEAAAC8AQAAEgEDAAEAAAABAAAAFgEDAAEAAAC8AgAAFwEEAAEAAABgIAAAGgEFAAEAAACoAAAAGwEFAAEAAACwAAAAJQEEAAEAAAAAAAAAKAEDAAEAAAACAAAAMQECABMAAAByAAAAMgECABQAAACGAAAAOwECAA0AAACaAAAAAAAAAAAA/+WlmZI5ZhXE8bEPZcOamfDNI4ZRIFPilAcnjbM2YCW0gnw/kEHaacOw9IP6L980+z1m85B6NG5o3OadbSRp7dIJv20//rSb29tLHrt9cER//1ff4Ijzdduq/dK1/9Or3V21vr/+8haZEwU3H/VsUyEZgs9b/pX/TDC/q7QYe1//2evOQawmIIj//ea3f1/j/psMt1/oeG91deqf+491rf2Ntd6nn/20m10p58/+mwlphJb/7NIK2EsKl1DCV2IXFU/yCD3imKiF3YYrhhcLtf7BhBhQlbwwoiIiIiIiIiIiPyKg2ncAVQWoIGUsCkCyRwyRIQYRApAceeDDmHKsm5TlDlDkNHFcU54KIKHKgw5Xl2Q7kUck5nOORHOOW5Q4cIjKgwi
G"
(Obviously I didn't post the whole string)


When I go back to NovaInfo's web site and look at the check image,
it's mostly black. I know the problem's not with the scanner. I'm
wondering if it's with the actual encoded string I'm getting from it,
or just the way I'm posting it.
 
G

Guest

post variables re limited to 256 characters or there abouts.... anyways I
know there's a limit on how long the string can be....

Try using the header to store the post data

web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
PostData = Encoding.ASCII.GetBytes(strData)
web.Headers.Add("PostData", PostData)

Try
result = web.UploadData(URL, "POST", PostData)
Catch
ResultString = "Failure|No connection to the process server"
GoTo Exit_Function
End Try

on the server side you will need to pull the PostData out of the header

here's an asp file that will do it and send an xml reponse back

<%@ Language=VBScript %>
<%

on error resume next

dim fso
dim tempfile
dim f

set fso = server.CreateObject("Scripting.FileSystemObject")
'fso.getspecialfolder(2) will return the global system temporary folder, on
windows 2003 this is usually \WINDOWS\TEMP\
tempfile = fso.GetSpecialFolder(2) & fso.GetTempName()

tempfile = left(tempfile,len(tempfile) - 3)
tempfile = tempfile & "xml"

set f = fso.CreateTextFile(tempfile)

f.write request.ServerVariables("HTTP_PostData")
f.close

response.ContentType = "text/xml"
response.Write "<datauploadresult>"
if err <> 0 then
response.Write "<result>" & err.number & " " & err.Description & "</result>"
else
response.Write "<result>Success</result>"
end if
response.Write "<tempfilename>" & tempfile & "</tempfilename>"
response.Write "</datauploadresult>"

%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top