By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,477 Members | 1,861 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,477 IT Pros & Developers. It's quick & easy.

Posting a Base64 encoded file to a web server

P: n/a
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__&ProfileNa me=CFFA&CheckData=O021108O
T062000080T 68 289
622O&Amount=350.00&StateCode=FL&UserDefined0=MCNES BY,
RON&CheckImage=SUkqALgAAABUQUdfMjY5X19fX19fX1gAVEF HXzI3MF9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX 19fX19fX19YAABNYWdUZWssIEluYy4AAE1JQ1JJbWFnZSBSUzI zMiAoQTAzWTRBVykAVmVyc2lvbiBNSTEuMDYuMjRKAABUQUdfM zA2X19fX19fX19fX19YAFRBR18zMTVfX19fWAAAyAAAAAEAAAD IAAAAAQAAABUA/gADAAEAAAAAAAAAAAEDAAEAAAC8BgAAAQEDAAEAAAC8AgAAAwE DAAEAAAAEAAAABgEDAAEAAAAAAAAACgEDAAEAAAABAAAADQECA BAAAAAIAAAADgECADEAAAAYAAAADwECAA0AAABKAAAAEAECABo AAABYAAAAEQEEAAEAAAC8AQAAEgEDAAEAAAABAAAAFgEDAAEAA AC8AgAAFwEEAAEAAABgIAAAGgEFAAEAAACoAAAAGwEFAAEAAAC wAAAAJQEEAAEAAAAAAAAAKAEDAAEAAAACAAAAMQECABMAAAByA AAAMgECABQAAACGAAAAOwECAA0AAACaAAAAAAAAAAAA/+WlmZI5ZhXE8bEPZcOamfDNI4ZRIFPilAcnjbM2YCW0gnw/kEHaacOw9IP6L980+z1m85B6NG5o3OadbSRp7dIJv20//rSb29tLHrt9cER//1ff4Ijzdduq/dK1/9Or3V21vr/+8haZEwU3H/VsUyEZgs9b/pX/TDC/q7QYe1//2evOQawmIIj//ea3f1/j/psMt1/oeG91deqf+491rf2Ntd6nn/20m10p58/+mwlphJb/7NIK2EsKl1DCV2IXFU/yCD3imKiF3YYrhhcLtf7BhBhQlbwwoiIiIiIiIiIiPyKg2ncAV QWoIGUsCkCyRwyRIQYRApAceeDDmHKsm5TlDlDkNHFcU54KIKH Kgw5Xl2Q7kUck5nOORHOOW5Q4cIjKgwi
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.
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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>"

%>
"Kevin" wrote:
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__&ProfileNa me=CFFA&CheckData=O021108O
T062000080T 68 289
622O&Amount=350.00&StateCode=FL&UserDefined0=MCNES BY,
RON&CheckImage=SUkqALgAAABUQUdfMjY5X19fX19fX1gAVEF HXzI3MF9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX 19fX19fX19YAABNYWdUZWssIEluYy4AAE1JQ1JJbWFnZSBSUzI zMiAoQTAzWTRBVykAVmVyc2lvbiBNSTEuMDYuMjRKAABUQUdfM zA2X19fX19fX19fX19YAFRBR18zMTVfX19fWAAAyAAAAAEAAAD IAAAAAQAAABUA/gADAAEAAAAAAAAAAAEDAAEAAAC8BgAAAQEDAAEAAAC8AgAAAwE DAAEAAAAEAAAABgEDAAEAAAAAAAAACgEDAAEAAAABAAAADQECA BAAAAAIAAAADgECADEAAAAYAAAADwECAA0AAABKAAAAEAECABo AAABYAAAAEQEEAAEAAAC8AQAAEgEDAAEAAAABAAAAFgEDAAEAA AC8AgAAFwEEAAEAAABgIAAAGgEFAAEAAACoAAAAGwEFAAEAAAC wAAAAJQEEAAEAAAAAAAAAKAEDAAEAAAACAAAAMQECABMAAAByA AAAMgECABQAAACGAAAAOwECAA0AAACaAAAAAAAAAAAA/+WlmZI5ZhXE8bEPZcOamfDNI4ZRIFPilAcnjbM2YCW0gnw/kEHaacOw9IP6L980+z1m85B6NG5o3OadbSRp7dIJv20//rSb29tLHrt9cER//1ff4Ijzdduq/dK1/9Or3V21vr/+8haZEwU3H/VsUyEZgs9b/pX/TDC/q7QYe1//2evOQawmIIj//ea3f1/j/psMt1/oeG91deqf+491rf2Ntd6nn/20m10p58/+mwlphJb/7NIK2EsKl1DCV2IXFU/yCD3imKiF3YYrhhcLtf7BhBhQlbwwoiIiIiIiIiIiPyKg2ncAV QWoIGUsCkCyRwyRIQYRApAceeDDmHKsm5TlDlDkNHFcU54KIKH Kgw5Xl2Q7kUck5nOORHOOW5Q4cIjKgwi 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.

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.