Quantcast
Channel: Tópicos
Viewing all articles
Browse latest Browse all 11336

Get Header

$
0
0
Penso que te estejas a referir a isto: Public Function pvPostFile(sUrl As String, sFileName As String, Optional ByVal bAsync As Boolean) As String 'Const STR_BOUNDARY As String = "3fbd04f5-b1ed-4060-99b9-fca7ff59c113" Dim nFile As Integer Dim baBuffer() As Byte Dim sPostData As String '--- read file nFile = FreeFile Open sFileName For Binary Access Read As nFile If LOF(nFile) > 0 Then ReDim baBuffer(0 To LOF(nFile) - 1) As Byte Get nFile, , baBuffer sPostData = StrConv(baBuffer, vbUnicode) End If Close nFile '--- prepare body sPostData = "Content-Disposition: form-data; filename=""" & Mid$(sFileName, InStrRev(sFileName, "\") + 1) & vbCrLf & _ "Content-Type: application/octet-stream" & vbCrLf & vbCrLf & _ sPostData & vbCrLf '--- post With CreateObject("MSXML2.XMLHTTP.6.0") .Open "POST", sUrl, bAsync .SetRequestHeader "Content-Type", "application/x-www-form-urlencoded" .SetRequestHeader "Content-Type", "multipart/form-data;" .SetRequestHeader "Name", FindLastModified .SetRequestHeader "Connection", "close" .Send pvToByteArray(sPostData) If Not bAsync Then pvPostFile = .ResponseText End If End With End Function Private Function pvToByteArray(sText As String) As Byte() pvToByteArray = StrConv(sText, vbFromUnicode) End Function É em VBA, o código que uso para enviar os ficheiros para o servidor

Viewing all articles
Browse latest Browse all 11336

Trending Articles