How to create an POS开发者_开发百科T with the HttpWebRequest Class in VB.net (2008)? I can find exemples with text only but not with text and files. Thanks.
You should be able to read the file in a buffer, and upload it to the server. It is not that difficult.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method "POST";
Stream fileStream = File.OpenRead("filename");
byte [] buffer = new byte[1024];
Stream reqStream = request.GetRequestStream();
int read = fileStream.Read(buffer, 0, buffer.Length);
while(read > 0)
{
reqStream.Write(buffer,0,read);
read fileStream.Read(buffer, 0, buffer.Length);
}
reqStream.Close();
fileStream.Close();
// now get the response...
Does that help?
精彩评论