the real problem is the CGI doesn't receive the total number of bytes from the image but lower number, so I can save an image in the server but it can't be seen because is incomplete . I think the problem is in this method....
This is the method which I use to send the request and to receive the answer,
Expand|Select|Wrap|Line Numbers
- public String enviarImagen(String chorro)
- {
- String parametro = "imagen=" + chorro;
- System.Net.HttpWebRequest cliente = (HttpWebRequest)WebRequest.Create("http://localhost/cgi-bin/subirImagen.pl");
- cliente.Method = "POST";
- byte[] bytesparametros = Encoding.ASCII.GetBytes(parametro);
- Stream os = null;
- try
- { // send the Post
- cliente.ContentLength = bytesparametros.Length; //Count bytes to send
- os = cliente.GetRequestStream();
- //Send it
- os.Write(bytesparametros, 0, bytesparametros.Length);
- }
- catch (WebException ex)
- {
- MessageBox.Show(ex.Message, "HttpPost: Request error",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- finally
- {
- if (os != null)
- {
- os.Close();
- }
- }
- try
- {
- System.Net.WebResponse respuesta = cliente.GetResponse();
- StreamReader mensaje = new StreamReader(respuesta.GetResponseStream());
- String resultado = mensaje.ReadToEnd();
- mensaje.Close();
- return resultado;
- }
- catch (WebException e)
- {
- WebExceptionStatus status = e.Status;
- if (status == WebExceptionStatus.ProtocolError)
- {
- MessageBox.Show("The server returned protocol error ");
- // Get HttpWebResponse so that you can check the HTTP status code.
- HttpWebResponse httpResponse = (HttpWebResponse)e.Response;
- MessageBox.Show((int)httpResponse.StatusCode + " - "
- + httpResponse.StatusCode);
- }
- return e.Status.ToString();
- }
- catch (Exception ex)
- {
- return ex.ToString();
- }
- }