I want to upload file to a host by using WebClient class. I also want to pass some values which should be displayed in the $_POST array on the server part (PHP). I want to do it by one connect
I've used code bellow
using (WebClient wc = new WebClient())
{
wc.Encoding = Encoding.UTF8;
NameValueCollection values = new NameValueCollection();
values.Add("client", "VIP");
values.Add("name", "John Doe");
wc.QueryString = values; // this displayes in $_GET
byte[] ans= wc.UploadFile(address, dumpPath);
}
If i've used QueryString property, the values displayed in $_GET array.But i want to send it by post method
There's nothing built-in that allows you to do that. I have blogged about an extension that you could use. Here are the relevant classes:
and now you could use it in your application:
Now in your PHP script you could use the
$_POST["client"]
,$_POST["name"]
and$_FILES["file"]
.