..:: MX Studio Fóruns ::..: Base64 Encoding para Imagens - ..:: MX Studio Fóruns ::..

Jump to content

Publicidade




Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Base64 Encoding para Imagens

#1 User is online   xanburzum 

  • Group: Administrador
  • Posts: 2073
  • Joined: 04-November 08

Posted 29 September 2011 - 07:15 PM

Public Function imgBinary(path)
                If (inStr(Request.ServerVariables("HTTP_USER_AGENT"),"MSIE") = 0) Then
                        Dim str : Set str = Server.CreateObject("ADODB.Stream")
                        Dim bin
                        
                        If (inStr(path,"://") = 0) Then
                           str.type = 1
                           str.open()
                           str.loadFromFile(Server.MapPath(path))
                           bin = str.read()
                        Else
                           dim srv : set srv = Server.CreateObject("Msxml2.ServerXMLHTTP")
                           srv.Open "GET", path, false
                           srv.Send()
                           str.Type = 1
                           str.Open
                           bin = srv.responseBody
                           Set srv = Nothing
                        End If

                        Dim open : Set open = Server.CreateObject("MSXML2.DOMDocument.6.0")
                        Dim src  : Set src = open.CreateElement("data")

                        src.dataType = "bin.base64"
                        src.nodeTypedValue = bin

                        path = "data:image/jpg;base64," & src.text

                        str.Close()

                        Set str  = Nothing
                        Set src  = Nothing
                        Set open = Nothing
                End If
                
                imgBinary = path
        End Function

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic



Publicidade




1 User(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)