S
supster
Hello, I am trying to use HttpWebRequest to simulate sending some POST
data from a form to a PHP script.
I have accomplished this using:
HttpWebRequest req = (HttpWebRequest)
WebRequest.Create("http://mysite.com/index.php");
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
string postData = "var=value1&var2=value2"
req.ContentLength = postData.Length;
StreamWriter stOut = new
StreamWriter(req.GetRequestStream(),
System.Text.Encoding.ASCII);
stOut.Write(postData);
stOut.Close();
I have now ran into a problem when I am trying to upload a file. The
PHP script expects a file uploaded from a form with the:
<input type="file">
object.
I have tried many things and can not figure out how to do this from
C#. Any help is greatly appreciated!
data from a form to a PHP script.
I have accomplished this using:
HttpWebRequest req = (HttpWebRequest)
WebRequest.Create("http://mysite.com/index.php");
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
string postData = "var=value1&var2=value2"
req.ContentLength = postData.Length;
StreamWriter stOut = new
StreamWriter(req.GetRequestStream(),
System.Text.Encoding.ASCII);
stOut.Write(postData);
stOut.Close();
I have now ran into a problem when I am trying to upload a file. The
PHP script expects a file uploaded from a form with the:
<input type="file">
object.
I have tried many things and can not figure out how to do this from
C#. Any help is greatly appreciated!