首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在windows phone 7中将字节图像发送到服务?

如何在windows phone 7中将字节图像发送到服务?
EN

Stack Overflow用户
提问于 2012-05-25 14:05:54
回答 1查看 723关注 0票数 1
代码语言:javascript
复制
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();
}

我写了上面的代码来发送图片作为字节。它没有给出任何errors.but图片没有正确上传。我在下面的代码中传递图像的base64字符串。

代码语言:javascript
复制
byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(str);

请告诉我什么是wrong.why图像没有正确上传?

EN

回答 1

Stack Overflow用户

发布于 2012-05-25 14:13:24

看看这个:Photo upload with parameters to a PHP page

这个是:http://nediml.wordpress.com/2012/05/10/uploading-files-to-remote-server-with-multiple-parameters/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10749283

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档