To simply send a file, .NET has this built-in. Very easy to use.
System.Net.WebClient webClient = new System.Net.WebClient();
webClient.UploadFileAsync(new Uri(anURL), aFile);
However, I needed to specify the file name and send other parameters, so here's what I did with the help of Krystalware.HttpUploadHelper:
// my files to upload
UploadFile[] files = new UploadFile[] {
new UploadFile(aFile, "aFileName", "application/zip")
};
// form data
NameValueCollection form = new NameValueCollection();
form["guid"] = guid;
HttpUploadHelper.Upload(anURL, files, form);
No comments:
Post a Comment