locked
How to upload the image in server? RRS feed

  • Question

  • how to upload the image in server using c# in windows store app...
    • Moved by Eason_H Thursday, January 2, 2014 8:52 AM
    Thursday, January 2, 2014 7:37 AM

Answers

All replies

  • Hi krishnacse12,

    Since the issue regards windows store app. I will move the question to the windows store forums. It is appropriate and more experts will assist you.

    Thanks


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 2, 2014 8:54 AM
  • Hello krishnacse12, 

    try to convert image -> base64 string, then send to server. In server side create one method that accept base64 string then convert to image.

    Thursday, January 2, 2014 9:08 AM
  • Hi,

    You can use the HttpClient class in Windows.Web.Http
    namespace to upload and download various types of content from an HTTP server
    in Windows Store apps. See how to use the  HttpClient class  to send a GET request to a web service.
    And you can refer to the sample: http://code.msdn.microsoft.com/windowsapps/HttpClient-sample-55700664

    Also, you can the Windows.Networking.BackgroundTransfer APIs provided in the Windows Runtime to enhance your Windows Store app with advanced file download and upload features that run in the background during app suspension, demonstrate
    per operation lifecycle management, and persist beyond app termination. See
    Uploading a file

    And you can see Background Transfer Download sample



    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.



    • Edited by Anne Jing Thursday, January 2, 2014 9:27 AM edit
    • Marked as answer by Anne Jing Friday, January 10, 2014 7:30 AM
    Thursday, January 2, 2014 9:12 AM

  • by this way i try to upload the image in server...

    if (imageBytes != null)
                        {
                            strPostdata = System.Convert.ToBase64String(imageBytes);
                        }
                        else
                        {
                            MessageDialog msg = new MessageDialog("Please Browse Picture.");
                            msg.ShowAsync();
                            txtImg.Text = "Enter....";
                            popupAddPicture.IsOpen = true;
                        }
                        var parameters = new List<KeyValuePair<string, string>>
                            {
                                new KeyValuePair<string,string>("stype", "wall_post"),
                                new KeyValuePair<string,string>("postby_id", App.pblLogDetail.member_id),
                                new KeyValuePair<string,string>("pt_content", txtImg.Text),
                                new KeyValuePair<string,string>("up_img",strPostdata),
                                new KeyValuePair<string ,string>("img_name",strImagename)
                            };

    HttpClient httpClient = new HttpClient();
    httpClient.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; TFMobile; Trident/6.0)");
    HttpContent content = new FormUrlEncodedContent(parameters);
    var response = await httpClient.PostAsync(App.url, content);
    var responseString = await response.Content.ReadAsStringAsync();

    Tuesday, February 25, 2014 4:01 AM