Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

post a file to an https site

Status
Not open for further replies.

tman24m

Programmer
May 21, 2001
93
US
Hey all,
I'm writing a console app in vb.net that needs to upload a file to a secured website. The website has a logon page and then a couple more buttons to get you to the submit page where you upload the file. Does anyone know what the process would be for this? Here is what i've got but it's returning HTML in the response.

Public Sub Upload(ByVal filePath As String)

Dim myWebClient As New WebClient
Dim responseArray As Byte()
Dim strFileName As String
Dim strDestination As String
Dim strURL As String

strURL = "someURL"

Console.WriteLine("Logging onto secure site.")
myWebClient.Credentials = New System.Net.NetworkCredential("user", "pwd")

Console.WriteLine("Getting file.")
strFileName = filePath.Substring(filePath.LastIndexOf("\") + 1)
strDestination = strURL & strFileName

Console.WriteLine("Posting file to " & strURL)
responseArray = myWebClient.UploadFile(strDestination, "POST", filePath)
Console.WriteLine(responseArray.Length & " Bytes posted to " & strURL)
Console.WriteLine(ControlChars.Cr + "Response Received.The contents of the file uploaded are: " + ControlChars.Cr + "{0}", Encoding.ASCII.GetString(responseArray))

End Sub



which returns

<HTML> Received.The contents of the file uploaded are:
<TITLE>File Transfer</TITLE>

<FRAMESET BORDER=1 ROWS="130,*,75" FRAMEBORDER="0" BORDERCOLOR="#ffffff">

<FRAME
SRC="/mb/head.cgi"
Scrolling="no"
NORESIZE="NORESIZE">

<FRAME
SRC="/servlet/MailboxServlet?operation=LOGON&remote=userName&pas
sword=pwd&mailbox_server=serverName&Submit=logon"
NORESIZE="NORESIZE"
NAME="View Frame"
SCROLLING="AUTO">

<FRAME
SRC="/cmwao/html/foot.htm"
Scrolling="no"
NORESIZE="NORESIZE">

<NOFRAMES>
<P>No frame suport</P>
</NOFRAMES>

</FRAMESET>
</HTML>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top