Binary Data, Base 64, ASP/VBScript

Results 1 to 2 of 2

Thread: Binary Data, Base 64, ASP/VBScript

  1. #1
    Gary Walker Guest

    Default Binary Data, Base 64, ASP/VBScript

    Hi,<BR><BR>I have a problem. I am trying to send an XML document to an ASP page, which is the easy bit. However in the XML document I have embedded a Graphics file (.gif, .jpg) using Base64 Encoding. The code for generating this bit of the XML document looks like the code shown below where DOCPATH is a full path pointing the file binary I wish to embed in the XML document.<BR><BR>My problem is that once the ASP page gets the XML document I cannot get the conversion back to Binary data to work. I know that part of the problem is the fact that all variables in VBScript are of type Variant and I need a "Byte" or Binary type variable to hold the decoded data.<BR><BR>Does anybody have any ideas how I can do this easily ysing MS XMLDom????<BR><BR><BR>Many thanks in advance!#<BR><BR><BR><BR><BR><BR>&#039; Use DataType so MSXML will validate the data type<BR> oEle.dataType = "bin.base64"<BR> <BR>&#039; Read in the data<BR> oEle.nodeTypedValue = ReadBinData(DOCINPATH)<BR><BR><BR>Function ReadBinData(ByVal strFileName As String) As Variant<BR> Dim lLen As Long<BR> Dim iFile As Integer<BR> Dim arrBytes() As Byte<BR> Dim lCount As Long<BR> Dim strOut As String<BR> <BR>&#039;Read from disk<BR> iFile = FreeFile()<BR> Open strFileName For Binary Access Read As iFile<BR> lLen = FileLen(strFileName)<BR> ReDim arrBytes(lLen - 1)<BR> Get iFile, , arrBytes<BR> Close iFile<BR> <BR> ReadBinData = arrBytes<BR>End Function

  2. #2
    Antony Welford Guest

    Default RE: Binary Data, Base 64, ASP/VBScript

    I use this.<BR><BR>ASP to get binary data out of XML<BR><BR> mvarXML.loadXML SOAPEnvelope &#039;stream of XML<BR> <BR> Set oImageDataNode = mvarXML.selectSingleNode("SOAP:Envelope/SOAP:Body/image/imagedata")<BR> ImageData = oImageDataNode.nodeTypedValue<BR><BR> &#039;Use a VB component to save the binary data to a file<BR> mvarBinaryFile.Save "c: est.gif",Imagedata<BR><BR><BR>&#039;this code is in the binary access component<BR><BR>Public Function Save(FilePath As String, btArr() As Byte) As Boolean<BR><BR> Dim x As Integer<BR> <BR> Open FilePath For Binary As #1<BR> Put #1, 1, btArr<BR> Close #1<BR>End Function<BR><BR><BR>That works for me.<BR><BR>Cheers<BR><BR>Antony<BR>-------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts