[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

vb post data to web site

Posted on 2006-06-24
5
Medium Priority
?
243 Views
Last Modified: 2008-01-09
Hello
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?
Thanks
0
Comment
Question by:john_123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 16977982
Hi,

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.

BFN,

fp.

0
 
LVL 1

Author Comment

by:john_123
ID: 16978943
Hi
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", "http://website.com/update.php", False)
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
xmlhttp.send("probe_id=2&stuff=2")
MsgBox(xmlhttp.ResponseText)
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?
0
 
LVL 1

Author Comment

by:john_123
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)
        Microsoft.VisualBasic.FileClose(1)

        Dim xmlhttp As Object
        xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
        xmlhttp.Open("POST", "http://www.website.com/update.php", 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 & _
           "--AaB03x"
        xmlhttp.send(System.Text.Encoding.Default.GetBytes(strBody))
        MsgBox(xmlhttp.ResponseText)
        xmlhttp = Nothing
0
 
LVL 5

Accepted Solution

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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

649 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