Send file+parameters in post request

后端 未结 2 1654
-上瘾入骨i
-上瘾入骨i 2020-12-05 11:29

I\'m using this code to send parameters to a webpage and getting correct response from it.

System.Net.WebClient oWeb = new System.Net.WebClient();
oWeb.Proxy         


        
2条回答
  •  既然无缘
    2020-12-05 12:06

    Use WebClient.QueryString to pass name/value pairs associated with the request.

    NameValueCollection parameters = new NameValueCollection();
    parameters.Add("value1", "123");
    parameters.Add("value2", "xyz");
    oWeb.QueryString = parameters;
    var responseBytes = oWeb.UploadFile("http://website.com/file.php", "path to file");
    string response = Encoding.ASCII.GetString(responseBytes);
    

提交回复
热议问题