//POST 방식으로 데이터를 업로드 하는 예제 입니다.
using System;
using System.Net;
using System.IO;
using System.Text;
using System.Web;
class OpenWrite
{
static void Main()
{
string uriString = "http://***.***.***.**/write_ok.php";
string name = "tester";
string email = "oracler@oraclejava.co.kr";
string subject = "방가와요...";
string password = "1111";
string memo = "사이트 오픈을 축하 합니다.";
string id = "guest";
string postData = "id=" + HttpUtility.UrlEncode(id) + "&" +
"name=" + HttpUtility.UrlEncode(name) + "&" +
"email=" + HttpUtility.UrlEncode(email) + "&" +
"subject" + HttpUtility.UrlEncode(subject) + "&" +
"password=" + HttpUtility.UrlEncode(password) + "&" +
"memo" + HttpUtility.UrlEncode(memo);
byte[] postArray = Encoding.Default.GetBytes(postData);
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
// postStream implicitly sets HTTP POST as the request method.
Console.WriteLine("Uploading to {0} ...", uriString);
Stream postStream = myWebClient.OpenWrite(uriString);
postStream.Write(postArray,0,postArray.Length);
// Close the stream and release resources.
postStream.Close();
Console.WriteLine("\n 방명록에 성공적으로 글을 올렸습니다...");
}
}
using System;
using System.Net;
using System.IO;
using System.Text;
using System.Web;
class OpenWrite
{
static void Main()
{
string uriString = "http://***.***.***.**/write_ok.php";
string name = "tester";
string email = "oracler@oraclejava.co.kr";
string subject = "방가와요...";
string password = "1111";
string memo = "사이트 오픈을 축하 합니다.";
string id = "guest";
string postData = "id=" + HttpUtility.UrlEncode(id) + "&" +
"name=" + HttpUtility.UrlEncode(name) + "&" +
"email=" + HttpUtility.UrlEncode(email) + "&" +
"subject" + HttpUtility.UrlEncode(subject) + "&" +
"password=" + HttpUtility.UrlEncode(password) + "&" +
"memo" + HttpUtility.UrlEncode(memo);
byte[] postArray = Encoding.Default.GetBytes(postData);
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
// postStream implicitly sets HTTP POST as the request method.
Console.WriteLine("Uploading to {0} ...", uriString);
Stream postStream = myWebClient.OpenWrite(uriString);
postStream.Write(postArray,0,postArray.Length);
// Close the stream and release resources.
postStream.Close();
Console.WriteLine("\n 방명록에 성공적으로 글을 올렸습니다...");
}
}