asp将base64编码的图片信息还原为图片

  asp将base64编码的图片信息还原为图片,可以将得到的base64编码的图片内容保存为一个xml文件(或者组合成下面贴出的xml格式的字符串,此时注意xml组件调用的方法不同于xml文件),通过MSXML2.DOMDocument+ADODB.Stream保存为图片文件。

 

  base.xml文件内容

    <?xml version="1.0" encoding="gb2312"?>  
    <data>  
    <![CDATA[iVBORw0KGgoAAAANSUhEUgAAAQ4AAAEsCAYAAAAy1V2YAAAJCElEQVR42u3dDYobORAG0Nwpd8qdcqfcaReziBRFSSp192SD/R6YhFnPxLNYn6XS37dvAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAME//FW8IxEcCA4EB4IDBIfgAMEhOEBwCA4QHAgOBAeCA8GB4ADBIThAcAgOEBwIDgQHggPBgeAAwSE4QHAIDhAcCA4EB4IDwYHgAMEhOEBwCA4QHP+3X796z/v58/dDcCA4mo3r1WB+/Pjd0F5/xkf1/Nej0zDzz3rqsQuC1+/TeY2v//567ut/n+BAcBwEx/fv/z1GwxmNKX5t1tBWDTP+7Nfz899XX1s9p3pdOTg6zxtmv6vgQHBsGlnucYzGVPU4uo0yPnf8G3cfIzxW//boFXV7EYIDwXHY26gazSo4YtBc/fl3ahaz13VnuCI4EByHvY3Xt8Xexq7Bx+95Ijh2NYv8uk56O516yGnvRHDw0cERG0wOgdkne6xvjLCJMxL5031WPzkZ+owezvj5sx5S7AnNHnlIFnscsX5SPbozNIKDtw6O0dByCIwGlmsTIxRGIxuPWLTc9VxiCFSFzKpx5qCqnlu9rtmj+nc6wXGhN+IdyfsFR2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BwgOAQHCA4BAcIDgQHggPBgeBAcIDgEBwgOAQHCA7BAYIDwYHgQHAgOBAcIDgEBwAAAAAAAAAAAAAAAAAAAADAo/4F6+HmEPy+t9QAAAAASUVORK5CYII=]]>  
    </data>  

  asp将base64编码的图片信息存储为图片

Dim xml : Set xml=Server.CreateObject("MSXML2.DOMDocument")   
Dim stm : Set stm=Server.CreateObject("ADODB.Stream")   
xml.resolveExternals=False
''''''''''''''''''方式1,从文件加载base64图片编码信息
xml.load Server.MapPath("base.xml")
''''''''''''''''''方式1结束
'''''''''''''''''方式2,加载xml格式的字符串,字符串格式如上面贴出来的base.xml内容
'xmlStr="......格式同上面的"
'xml.loadXML(xmlStr)
''''''''''''''''''方式2结束


xml.documentElement.setAttribute "xmlns:dt","urn:schemas-microsoft-com:datatypes"   
xml.documentElement.dataType = "bin.base64"   
stm.Type=1 'adTypeBinary   
stm.Open   
stm.Write xml.documentElement.nodeTypedValue   
stm.SaveToFile Server.MapPath("12.png")   
stm.Close   
Set xml=Nothing   
Set stm=Nothing 

来源:http://blog.csdn.net/plcc123/article/details/9358277

评论(0)网络
阅读(941)喜欢(0)不喜欢(0)Asp/VBScript