English 中文(简体)
如何发送字节图像到窗口电话 7 的服务?
原标题:How to send bytes image to service in windows phone 7?
void SendPost()
            {
                var url = "http://{ipaddress}/Network/Records/Registration?fname=tt&lname=tt&username=dddddddd&password=tt";

                HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
                myRequest.Method = "POST";
                myRequest.ContentType = "application/x-www-form-urlencoded";

                myRequest.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), myRequest);
    }
void GetRequestStreamCallback(IAsyncResult asynchronousResult)
        {
            HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
            System.IO.Stream postStream = request.EndGetRequestStream(asynchronousResult);
            string parametersString = "";


            byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(str);
            // Write to the request stream.
            postStream.Write(byteArray, 0, byteArray.Length);
            postStream.Close();
            // Start the asynchronous operation to get the response
            request.BeginGetResponse(new AsyncCallback(GetResponseCallback), request);
}



 void GetResponseCallback(IAsyncResult asynchronousResult)
        {

                HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
                HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
                Stream streamResponse = response.GetResponseStream();
                StreamReader streamRead = new StreamReader(streamResponse);
                string responseString = streamRead.ReadToEnd();
                // Close the stream object
                streamResponse.Close();
                streamRead.Close();
                // Release the HttpWebResponse
                response.Close();
}

I wrote above code for sending image as bytes.it s not giving any errors.but image was not uploading properly. i am passing base64 string of image in below code.

byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(str);

请告诉我什么是错的。 为什么图像没有正确上传?

问题回答

见:Photo上传带有参数的PHP页面

和以下的:< a href=""http://nediml.wordpress.com/2012/05/10/upaking-files-to-remote-server- with- multiple-paraters/"rel=“不跟随 nofollown noreferrerrr">http://nediml.wordpress.com/2012/05/10/uploaking-files-to-remote-server- with- multiple-paraters/





相关问题
WCF DataMember Serializing questions

Ok, so I was part way through the long winded process of creating DTOs for sending my model over the wire and I don t feel like I m going down the right route. My issue is that most of the entities ...

Access WCF service on same server

I have a .NET website with a WCF service. How do I access the current operations context of my service? One possible work around is to just make a call to the service within the app...but that seems ...

WCF binding error

So I got into work early today and got the latest from source control. When I try to launch our ASP.NET application, I get this exception: "The binding at system.serviceModel/bindings/wsHttpBinding ...

The service operation requires a transaction to be flowed

I am facing strange issue with our WCF service. The same code was working fine until recently we added more OperationContracts(Web Methods). We have common 3 tier architecture. DAL (WCF) BLL Web ...

热门标签