2011-02-08 79 views
0

HI任何機構可以告訴我如何解碼在ASP經典的一個base64字符串從圖像圖像解碼

+1

爲什麼這個問題被標記爲`JAVA`? – 2011-02-08 06:41:22

回答

0

在Java編碼傳遞的base64字符串轉換成decodeBase64()函數,如下面,並通過文件名,並返回值寫入writeBytes程序,圖像會在文件系統上創建

 
private function decodeBase64(base64) 
     dim DM, EL 
     Set DM = CreateObject("Microsoft.XMLDOM") 
     ' Create temporary node with Base64 data type 
     Set EL = DM.createElement("tmp") 
     EL.DataType = "bin.base64" 
     ' Set encoded String, get bytes 
     EL.Text = base64 
     decodeBase64 = EL.NodeTypedValue 
    end function 


private Sub writeBytes(file, bytes) 

     Dim binaryStream 
     Const TypeBinary = 1, ForWriting = 2 
     Set binaryStream = CreateObject("ADODB.Stream") 
     binaryStream.Type = TypeBinary 
     'Open the stream and write binary data 
     binaryStream.Open 
     binaryStream.Write bytes 
     'Save binary data to disk 
     binaryStream.SaveToFile file, ForWriting 
End Sub