asked on
this is the part of the xml that has the image.
<Image ImageFormat="PNG" dt:dt="bin.base64" xmlns:dt="urn:schemas-microsoft-com:datatypes">iVBORw0KGgoAAAANSUhEUgAAAp0AAAIvAQMAAAAMGfIDA....AAAAAElFTkSuQmCC</Image>
I'm using the following VBA:
Const sBASE_64_CHARACTERS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
Function fGetWebPost(strSourceURL As String, strRequest As String)
Dim xmlServerHttp As Object, co As Long, s As String
Set xmlServerHttp = CreateObject("MSXML2.ServerXMLHTTP.4.0")
With xmlServerHttp
.Open "POST", strSourceURL, False
'.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send (strRequest)
s = .responseText
End With
fGetWebPost = s
Open "c:\test.png" For Output As #1
Print #1, Base64decode(Mid(s, 1312, 11798))
Close #1
Set xmlServerHttp = Nothing
End Function
'**************************************
' Name: Base 64 Encode / Decode
' Description:Base 64 encodeing is used
' to convert binary files to a "safe" form
' at for transporting files through smtp (
' email) and other protocols. It is also u
' sed for basic authentication. With this
' code, you can decode the current UserNam
' e/Password who is visiting a protected p
' age on your site by requesting one of th
' e serverVariables.
' By: Lewis E. Moten III
'
' Inputs:These two algorithims are expec
' ting a string that is to be encoded or d
' ecoded.
'
' Returns:Returns a string that was enco
' ded or decoded.
'
' Side Effects:The string returned from
' encoding with Base64 is not delimited by
' cariadge returns. Some formats that I ha
' ve seen in the past, such as email - may
' continue to the next line after the 80th
' character.
'Also, these functions work With Strings. (Not binary data). When working with binary data, some changes may need To come into place.
'
'This code is copyrighted and has ' limited warranties.Please see http://w
' ww.Planet-Source-Code.com/vb/scripts/Sho
' wCode.asp?txtCodeId=6268&lngWId=4 'for details. '**************************************
' --------------------------------------
' ---------------------------------------
Function Base64decode(ByVal asContents)
Dim lsResult
Dim lnPosition
Dim lsGroup64, lsGroupBinary
Dim Char1, Char2, Char3, Char4
Dim Byte1, Byte2, Byte3
If Len(asContents) Mod 4 > 0 Then asContents = asContents & String(4 - (Len(asContents) Mod 4), " ")
lsResult = ""
For lnPosition = 1 To Len(asContents) Step 4
lsGroupBinary = ""
lsGroup64 = Mid(asContents, lnPosition, 4)
Char1 = InStr(sBASE_64_CHARACTERS, Mid(lsGroup64, 1, 1)) - 1
Char2 = InStr(sBASE_64_CHARACTERS, Mid(lsGroup64, 2, 1)) - 1
Char3 = InStr(sBASE_64_CHARACTERS, Mid(lsGroup64, 3, 1)) - 1
Char4 = InStr(sBASE_64_CHARACTERS, Mid(lsGroup64, 4, 1)) - 1
Byte1 = Chr(((Char2 And 48) \ 16) Or (Char1 * 4) And &HFF)
Byte2 = lsGroupBinary & Chr(((Char3 And 60) \ 4) Or (Char2 * 16) And &HFF)
Byte3 = Chr((((Char3 And 3) * 64) And &HFF) Or (Char4 And 63))
lsGroupBinary = Byte1 & Byte2 & Byte3
lsResult = lsResult + lsGroupBinary
Next
Base64decode = lsResult
End Function
test.txt
ASKER
Web development includes all aspects of presenting content on intranets and the Internet, including delivery development, protocols, languages and standards, server software, browser clients, databases and multimedia generation.
TRUSTED BY