views:

2708

answers:

2

Does anyone have a working example using HttpWebRequest in C# to submit a file from the local drive to a multipart/form-data web form?

+6  A: 

it is WAY easier to do this with WebClient

string url = "http://myserver/myapp/upload.aspx";
string file = "c:\\files\\test.jpg";
WebClient wc = new WebClient();
wc.UploadFile(url,"post",file);

If it needs to be httpwebrequest I can put something together for you (it is possible), but it will be more like 50 lines then 5

Matt Briggs
A: 

Matt, please post the HTTPWebRequest "50lines" example. I'm trying to upload from a smartphone and can't manage to do it right.

Would really appreciate your help. Mario

The WebClient class uses the WebRequest class to provide access to resources.
Sherlock