Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Uplode image to web service

$
0
0

Hello guys i am trying to uplode image i got the image and everything is fine but i want to send the file to my web service c# witch recive the file and user id parmtar please if any one could help me i will be very thankful to him and this my code that is not working :smile:

           MultipartFormDataContent formData = new MultipartFormDataContent();
            byte[] b = File.ReadAllBytes(SelectedImageFile.Path);
            var imageContent = new ByteArrayContent(b, 0, b.Length);
            imageContent.Headers.ContentType = MediaTypeHeaderValue.Parse("image/jpeg");
            formData.Add(imageContent, "file");
            formData.Add(new StringContent(App.UserGuid), "USERID_GUID");
            var httpClient = new System.Net.Http.HttpClient();
            var responseMsg = await httpClient.PostAsync(url, formData);
            var remotePath = await responseMsg.Content.ReadAsStringAsync();

Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>