vb post data to web site

Posted on 2006-06-24
Last Modified: 2008-01-09
I am using VB Express 2005 and would like ideas of how to automatically post data to a website.
I want to create an application which will periodically send it's results to a public web server over https so that it can be analysed. VB Express 2005 includes a Web Browser control if this helps.
My intention is to use the VB app to compress a file of results and then post that file to an appropriate server.
Any ideas?
Question by:john_123
  • 2
LVL 35

Expert Comment

by:[ fanpages ]
ID: 16977982

Speak to the owner of the server & ask how they can receive your file, or the contents of your file.

You may be able to post the entire file using a HTTP:// request, or you may need to stream the contents line by line (or character by character) to a pre-built data channel.




Author Comment

ID: 16978943
We are the owner of the server.
We need to periodically transfer an amount of statistical data to a web server for analysis.
Rather than writing a client/server to transfer data I thought it would be appopriate to simply post the data to the web server. This way I can also use HTTPS to encrypt it later.

I have gone down this path so far
Dim xmlhttp As Object
xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.Open("POST", "", False)
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
xmlhttp = Nothing

This only seems to allow me to send data separated by the & sign as part of the URL - I would like to use this to be able to submit a file.

Is there any better way to achieve this?

Author Comment

ID: 16979853
I think I have achieved my goal through the following...

  Dim strText As String, strBody As String
        Dim strFilename As String
        strFilename = "c:\results.txt"

        Microsoft.VisualBasic.FileOpen(1, strFilename, OpenMode.Binary, OpenAccess.Read)
        strText = New String(" ", LOF(1))
        Microsoft.VisualBasic.FileGet(1, strText)

        Dim xmlhttp As Object
        xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
        xmlhttp.Open("POST", "", False)
        xmlhttp.setRequestHeader("Content-Type", "multipart/form-data, boundary=AaB03x")
        strBody = _
           "--AaB03x" & vbCrLf & _
           "Content-Disposition: form-data; name=""probe_id""" & vbCrLf & vbCrLf & _
           "12345" & vbCrLf & _
           "--AaB03x" & vbCrLf & _
           "Content-Disposition: attachment; name=""FILE1""; filename=""" & strFilename & """" & vbCrLf & _
           "Content-Type: text/plain" & vbCrLf & vbCrLf & _
           strText & vbCrLf & _
        xmlhttp = Nothing

Accepted Solution

Netminder earned 0 total points
ID: 17164456
Closed, 500 points refunded.
Site Admin

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now