The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Psoting Files Using WebClient.UploadFile

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Doug Thews

Posts: 866
Nickname: dougthews
Registered: Jul, 2003

Doug Thews is a software developer/manager for D&D Consulting Services with 18+ years of experience
Psoting Files Using WebClient.UploadFile Posted: Jan 10, 2004 4:06 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Doug Thews.
Original Post: Psoting Files Using WebClient.UploadFile
Feed Title: IlluminatiLand
Feed URL: http://apps5.oingo.com/apps/domainpark/domainpark.cgi?client=netw8744&s=JETBRAINS.COM
Feed Description: A technology blog for people enlightened enough to think for themselves
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Doug Thews
Latest Posts From IlluminatiLand

Advertisement

I've seen quite a few questions on the boards int he past month regarding posting files using the UploadFile method of the WebClient class. So, I thought I'd post some information that may help answer some of the most common questions regarding posting files to a remote server using the HTTP POST command.

#1. When using the UploadFile method, you need to have a page on the destination web server that you post to (using HTTP POST). It's that web page that reads the file names (and other arguments), and saves the data to that server. So, just using UploadFile like this (without a file on that server) will not work.

myWebClient.UploadFile("http://www.myserver.com/", "POST", "c:\test.txt")

#2. When using the UploadFile method as shown below:

myWebClient = New WebClient
httpResponseArray = myWebClient.UploadFile(uriString, "POST", LocalFileName)

You need to remember that the uriString has to be the complete URL AND web page that is going to accept the HTTP POST data. UploadFile will not work when just specifying a directory, even if your web page is listed as the default page for that directory. So, if the page your calling is default.aspx, the uriString has to be: "http://www.myserver.com/default.aspx" and NOT "http://www.myserver.com/"
#3. You can use the BaseAddress property of the WebClient class to set a base address for all subsequent operations, and the specify the relative address from then on out.
#4. The byte stream returned from an UploadFile or UploadData request is actually the HTML returned from the page specified in uriString, and not a status of the transfer itself.

I'll try to add on things to this post as I catch them on the boards.

Read: Psoting Files Using WebClient.UploadFile

Topic: One other thing: I'll be in NYC with INETA on the 15th Previous Topic   Next Topic Topic: The New MSN - Too Loud?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use