Timetell - Hope this works for you - I'm using it on a Windows 7 64bit machine.
Code:
' Calling Routine
URL = "http://maps.google.com/?f=q&source=s_q&hl=en&geocode=&q=http://www.website.com/GoogleMaps/uploaded_files/files/"
URL = URL & SiteName & ".kml"
kmlFile = SiteName & ".kml"
URL = URL & "&sll=" & dLatitude & "," & dLongitude & "+++++++++++++*-----&sspn=0.104398,0.179043&layer=t&ie=UTF8&ll=" & dLatitude & "," & dLongitude
URL = URL & "&spn=0.001148,0.001399&t=h&z=20&lci=com.panoramio.all"
Call UploadRoutine(App.Path & "\GoogleEarth\" & kmlFile)
ShellExecute Me.hwnd, "open", URL, vbNullString, "", 0
exit sub
' this routine does all the work - it gathers the info required for the HTTP request
' and sends it via the winsock control
Private Sub UploadRoutine(FileName As String)
Dim strFile As String
Dim strHttp As String
Dim DestUrl As URL
' if a request is allredy being sent
' exit
If blnConnected Then Exit Sub
' check that a file was selected
If FileName = vbNullString Then
MsgBox "No File Chosen", vbCritical, "ERROR"
Exit Sub
End If
' extract the URL using a helper function
DestUrl = ExtractUrl("http://www.perfected.com/GoogleMaps/post_dump.php")
If DestUrl.Host = vbNullString Then
MsgBox "Invalid Host", vbCritical, "ERROR"
Exit Sub
End If
' clear the old response
txtResponse.Text = ""
' read the file contents as a string
' N.B: in HTTP everything is a string, even binary files
strFile = GetFileContents(FileName)
' build the HTTP request
strHttp = BuildFileUploadRequest(strFile, DestUrl, "File", FileName, "text/plain")
' assign the protocol host and port
Winsock1.Protocol = sckTCPProtocol
Winsock1.RemoteHost = DestUrl.Host
If DestUrl.Port <> 0 Then
Winsock1.RemotePort = DestUrl.Port
Else
Winsock1.RemotePort = 80
End If
' make the connection and send the HTTP request
Winsock1.Connect
While Not blnConnected
DoEvents
Wend
txtRequest = strHttp
Winsock1.SendData strHttp
DoEvents
End Sub
' this function builds a http request based on the following parameters:
'
' data = the data from the file to be uploaded
' DestUrl = a URL to containing information on where to send the data
' UploadName = the field upload name usually pass by <input type="file" name="uploadname"
' Filename = the name of the file
' The MIME type of the file
Private Function BuildFileUploadRequest(ByRef strData As String, _
ByRef DestUrl As URL, _
ByVal UploadName As String, _
ByVal FileName As String, _
ByVal MimeType As String) As String
Dim strHttp As String ' holds the entire HTTP request
Dim strBoundary As String 'the boundary between each entity
Dim strBody As String ' holds the body of the HTTP request
Dim lngLength As Long ' the length of the HTTP request
' create a boundary consisting of a random string
strBoundary = RandomAlphaNumString(32)
' create the body of the http request in the form
'
' --boundary
' Content-Disposition: form-data; name="UploadName"; filename="FileName"
' Content-Type: MimeType
'
' file data here
'--boundary--
strBody = "--" & strBoundary & vbCrLf
strBody = strBody & "Content-Disposition: form-data; name=""" & UploadName & """; filename=""" & _
FileName & """" & vbCrLf
strBody = strBody & "Content-Type: " & MimeType & vbCrLf
strBody = strBody & vbCrLf & strData
strBody = strBody & vbCrLf & "--" & strBoundary & "--"
' find the length of the request body - this is required for the
' Content-Length header
lngLength = Len(strBody)
' construct the HTTP request in the form:
'
' POST /path/to/reosurce HTTP/1.0
' Host: host
' Content-Type: multipart-form-data, boundary=boundary
' Content-Length: len(strbody)
'
' HTTP request body
strHttp = "POST " & DestUrl.URI & "?" & DestUrl.Query & " HTTP/1.0" & vbCrLf
strHttp = strHttp & "Host: " & DestUrl.Host & vbCrLf
strHttp = strHttp & "Content-Type: multipart/form-data, boundary=" & strBoundary & vbCrLf
strHttp = strHttp & "Content-Length: " & lngLength & vbCrLf & vbCrLf
strHttp = strHttp & strBody
BuildFileUploadRequest = strHttp
End Function