i want to upload file to a server .
i write this function to upload the file to localhost server (iam using wamp server)
private void button1_Click_1(object sender, EventArgs e)
{
FileStream fstream = new FileStream(@"C:\Users\Albert\Documents\10050409_3276.doc", FileMode.OpenOrCreate);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost/upload_file");
request.Method = "PUT";
request.ContentLength = fstream.Length;
request.AllowWriteStreamBuffering = true;
Stream request_stream = request.GetRequestStream();
byte[] indata = new byte[1024];
int bytes_read = fstream.Read(indata, 0, indata.Length);
while (bytes_read > 0)
{
request_stream.Write(indata, 0, indata.Length);
bytes_read = fstream.Read(indata, 0, indata.Length);
}
fstream.Close();
request_stream.Close();
request.GetResponse();
MessageBox.Show("ok");
}
so when i click on the button the exception apper said that :
Additional information: The remote server returned an error: (405) Method Not Allowed.
i try to use "POST" instead of "PUT" so the program work and the message box apper to say 'ok' but when i open the localhost->upload_file(folder) i didn't find any files .
so whats the problem ??
thanks

New Topic/Question
Reply




MultiQuote







|