Posting Text and file to a web form online
Posting Text and file to a web form online
Posting Text and file to a web form online
Posting Text and file to a web form online
Posting Text and file to a web form online
Posting Text and file to a web form online Posting Text and file to a web form online Posting Text and file to a web form online Posting Text and file to a web form online Posting Text and file to a web form online Posting Text and file to a web form online Posting Text and file to a web form online Posting Text and file to a web form online
Posting Text and file to a web form online Posting Text and file to a web form online
Posting Text and file to a web form online
Go Back  Xtreme Visual Basic Talk > > > Posting Text and file to a web form online


Reply
 
Thread Tools Display Modes
  #1  
Old 02-28-2005, 03:34 AM
Achilleterzo Achilleterzo is offline
Newcomer
 
Join Date: Feb 2005
Posts: 3
Default Posting Text and file to a web form online


Hi all, im trying to post text field and file field to an online form by VB..
the code i made is:

Code:
Sub PostForm()
        Dim userid As String = "aaa"
        Dim password As String = "bbb"
        Dim PhoneNumber As String = "123"
        Dim FormText As String = "Test di messaggio"
        Dim encoding As New System.Text.ASCIIEncoding
        Dim postdata As New System.Text.StringBuilder


        With postdata
            .Append("PhoneNumber=")
            .Append(PhoneNumber)
            .Append("&FormText=")
            '.Append(System.Web.HttpUtility.UrlEncode(FormText))
            .Append(FormText)
        End With

        Dim data As Byte() = encoding.GetBytes(postdata.ToString)

        Dim request As System.Net.HttpWebRequest
        request = System.Net.HttpWebRequest.Create("http://server.com/")

        Dim networkCredential As New networkCredential(userid, password)

        With request
            .PreAuthenticate = True
            .Credentials = networkCredential
            .Method = "POST"
            .ContentType = "multipart/form-data"
            .ContentLength = data.Length
        End With

        Dim sw As System.IO.Stream
        sw = request.GetRequestStream

        Try
            sw = request.GetRequestStream
            sw.Write(data, 0, data.Length)
            'sw.Write(File, 0, File.Lenght)
            sw.Close()
        Catch
            MsgBox(Err.Description & " SW error", MsgBoxStyle.Critical)
        End Try

        Dim response As System.Net.HttpWebResponse

        Try
            response = request.GetResponse
            Dim sr As New System.IO.StreamReader(response.GetResponseStream)
            Dim result As String = sr.ReadToEnd
            MsgBox(result, MsgBoxStyle.Information)
        Catch
            MsgBox(Err.Description, MsgBoxStyle.Critical)
        End Try
    End Sub
For the text all are ok, but now i dont know how to append a file header for submit to form...
any idea?

Last edited by Achilleterzo; 02-28-2005 at 03:48 AM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Posting Text and file to a web form online
Posting Text and file to a web form online
Posting Text and file to a web form online Posting Text and file to a web form online
Posting Text and file to a web form online
Posting Text and file to a web form online
Posting Text and file to a web form online Posting Text and file to a web form online Posting Text and file to a web form online Posting Text and file to a web form online Posting Text and file to a web form online Posting Text and file to a web form online Posting Text and file to a web form online
Posting Text and file to a web form online
Posting Text and file to a web form online
 
Posting Text and file to a web form online
Posting Text and file to a web form online
 
-->