Sådan her ser koden ud nu, og det virker som sagt ikke :(
Public Sub Inet_Upload(ByVal strFile As String, ByVal uname As String)
Dim intFree As Integer
Dim strUrl As String, _
strServerIp As String, _
strServerPort As String, _
strServerPage As String
Dim strData As String, _
strHeaders As String, _
strBoundary As String, _
strCommand As String
strServerIp = "192.168.2.10"
strServerPort = "80"
strServerPage = "upload.php"
strUrl = strServerIp & ":" & strServerPort & "/" & strServerPage
intFree = FreeFile()
Open strFile For Binary Access Read Lock Read Write As intFree
strData = Space(LOF(intFree))
Get #intFree, , strData
Close intFree
strBoundary = "---------------------------" & RndBoundary
strCommand = strBoundary & vbCrLf & "Content-Disposition: form-data; name=" & Chr(34) & "ufil" & Chr(34) & "; filename=" & Chr(34) & strFile & Chr(34) & vbCrLf & _
"Content-Type: application/octet-stream" & vbCrLf & vbCrLf & strData & vbCrLf & strBoundary & vbCrLf
strCommand = strCommand & "Content-Disposition: form-data; name=" & Chr(34) & "uname" & Chr(34) & vbCrLf & _
vbCrLf & vbCrLf & uname & vbCrLf & strBoundary & "--"
strHeaders = "Content-Type: multipart/form-data; boundary=" & strBoundary & vbCrLf _
& "Content-Length: " & CStr(Len(strCommand)) & vbCrLf
With frmMain.Inet1
.URL = "
http://" & strUrl
.Protocol = icHTTP
.Execute .URL, "POST", strCommand, strHeaders
End With
While frmMain.Inet1.StillExecuting
DoEvents
Wend
MsgBox frmMain.Inet1.GetChunk(9048)
End Sub
Private Function RndBoundary() As String
Dim i As Integer
Dim intRnd As Integer
Randomize
For i = 1 To 14
If i Mod 2 = 0 Then
intRnd = Int((25 * Rnd) + 1)
RndBoundary = RndBoundary & Chr$(intRnd + 64)
Else
intRnd = Int((8 * Rnd) + 1)
RndBoundary = RndBoundary & intRnd
End If
Next
End Function