string[] open = this.openFileDialog1.FileName.Split('\\'); string nome = open[open.Length - 1]; string[] temp = nome.Split('.'); string extension = temp[1]; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(this.indirizzo + "servletUpload/controllerFiles"); string post_data = this.openFileDialog1.FileName; string boundary = "AaB03x"; string useragent = "_Webclient_Meetecho 1.0"; req.UserAgent = useragent; req.ContentType = "multipart/form-data; boundary=" + boundary; req.Method = "POST"; byte[] contents = FileToByteArray(post_data); MemoryStream postData = new MemoryStream(); string newLine = "\r\n"; StreamWriter sw = new StreamWriter(postData); sw.Write("--" + boundary + newLine); sw.Write("Content-Disposition: form-data; name=\"myFile\"" +"; filename=" + "\"" + this.stanza + "-" + this.room + "."+extension + "\"" + newLine,"upload",this.openFileDialog1.FileName, newLine); sw.Write("Content-Type: application/octet-stream; charset=ISO-8859-1" + newLine); sw.Write("Content-Transfer-Encoding: binary" + newLine + newLine); sw.Write("VALUE" + newLine); sw.Write("--{0}--{1}", boundary, newLine); sw.Flush(); postData.Write(contents, 0, contents.Length); sw.Write(newLine); sw.Flush(); req.ContentLength = postData.Length; using (Stream s = req.GetRequestStream()) postData.WriteTo(s); postData.Close();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)