很多人不会用按键写HTTP上传文件的例子Function ReadBinaryFile(filePath)
Dim fs, file, stream, fileData
Set fs = CreateObject("Scripting.FileSystemObject")
' 检查文件是否存在
If Not fs.FileExists(filePath) Then
MsgBox "文件不存在:" & filePath
Exit Function
End If
Set stream = CreateObject("ADODB.Stream")
stream.Type = 1 ' 1 表示二进制
stream.Open
stream.LoadFromFile filePath
fileData = stream.Read
stream.Close
Set fs = Nothing
Set stream = Nothing
ReadBinaryFile = fileData
End Function
Function __HttpPost(posturl,params)
Dim oauth_http
Dim fileData
fileData = ReadBinaryFile(params)
MsgBox (posturl)
MsgBox(lenB(fileData))
Set oauth_http = CreateObject("MSXML2.ServerXMLHTTP")
oauth_http.Open "

OST", posturl, False
oauth_http.setRequestHeader "Content-Type", "application/octet-stream"
oauth_http.setRequestHeader "User-Agent", "Mozilla/4.0 (iMouse)"
oauth_http.send fileData
If oauth_http.Status = 200 Then
__HttpPost = UTF8ToANSI(oauth_http.responseText)
Else
__HttpPost = ""
End If
//
__HttpPost = StrConv(oauth_http.ResponseBody, vbUnicode)
//
__HttpPost = oauth_http.responseBody
Set oauth_http = Nothing
End Function
Function UTF8ToANSI(text)
UTF8ToANSI = text
End Function
返回值 = __HttpPost("http://127.0.0.1:18081/ocr0", "D:\PaddleOCR\PaddleOCR-2.9.1\deploy\cpp_infer\buildCPU\Release\imgs\2\03.png")
MsgBox(返回值)
至于百度飞桨本地架设,看这里:
https://blog.csdn.net/qq_41057894/article/details/144860067