Reputation:
C# provides functionality to submit a post request, but there is nothing about uploading an image/file on MSDN. I'd like to do this without using raw headers.
Upload files with HTTPWebrequest (multipart/form-data)
Upvotes: 0
Views: 4747
Reputation: 10249
My ASP.NET Upload FAQ has an article on this, with example code: Upload files using an RFC 1867 POST request with HttpWebRequest/WebClient. This code doesn't load files into memory, supports multiple files, and supports form values, setting credentials and cookies, etc.
Upvotes: 2
Reputation: 422280
You can use WebClient
class easily. It has an UploadFile
method:
var client = new WebClient();
client.UploadFile("http://server/upload.aspx", @"C:\file.jpg");
Upvotes: 3