Wednesday, July 1, 2009

Upload file from client to server+asp.net

How to Receive file in Server
if (Request.Files.Count > 0)
{
HttpPostedFile file = Request.Files["nameOfFile"];
file.SaveAs(Server.MapPath(file.FileName));
}

How to send file to server

using System.Net;

WebClient client = new WebClient();
byte[] responseArray = client.UploadFile("http://domain/FileHandler.aspx", "TestFile.txt");

No comments:

Post a Comment