Hello, TELOPHASE!
I'm not sure if you found the answer, here is how I do it:
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uploadUrl);
req.Method = "POST";
req.ContentLength = (long)postData.Length;
using(Stream s = req.GetRequestStream()) {
s.Write(postData.ToArray(), 0, (int)postData.Length);
postData.Close();
}
WebResponse resp = req.GetResponse();
resp.Close();
where: - uploadUrl is the address of an HTML page (see bellow) and postData is an MemoryStream containing data to be uploaded.
On server I have an aspx page with form enctype="multipart/form-data". On Page_Load...
byte[] theData = null;
if(Request.ServerVariables["REQUEST_METHOD"].ToString().ToUpper() == "POST") {
theData = Request.BinaryRead(Request.ContentLength);
string picName = "now.jpg";
FileStream stm = new FileStream(Server.MapPath("images/" + picName), System.IO.FileMode.Create);
stm.Write(theData, 0, (int)theData.Length);
stm.Close();
}
I used this for uploading pictures using an application deployed in a smartphone.
|