Function ImagesToBase64(FilePath)
Dim xml
Dim root
Dim fs
Dim objStream
Dim objXMLDoc
Dim Base64
Set objXMLDoc=CreateObject("Microsoft.XMLDOM")
objXMLDoc.loadXML "<?xml version='1.0' ?><data></data>"
Set fs = createObject("Scripting.FileSystemObject") ''FSO组件
If fs.FileExists(FilePath) Then '判断File文件是否存在
'用 stream 来读取数据
Set objStream = CreateObject("ADODB.Stream")
objStream.Type = 1
objStream.Open
objStream.LoadFromFile FilePath
objXMLDoc.documentElement.dataType = "bin.base64"
objXMLDoc.documentElement.nodeTypedvalue = objStream.Read
Set xml = CreateObject("Microsoft.XMLDOM")
xml.load objXMLDoc
If xml.ReadyState>2 Then
Set root=xml.getElementsByTagName("data")
Base64 = root.Item(0).Text
//TracePrint "Base64=" & Base64
Base64 = Replace(Base64,vbLf,"")
else
Base64=""
End If
Set xml=Nothing
Set objStream=Nothing
else
Base64=""
End If
Set fs=Nothing
Set objXMLDoc = Nothing
ImagesToBase64 = Base64
End Function
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
Img_base64 = ImagesToBase64("C:1.png")
data = "img=" + Img_base64 + "&lan=en"
post_url = "http://127.0.0.1:5689"
http.open "POST", post_url,False
http.send data
xmlBody = http.ResponseText
TracePrint xmlBody