Currently trying to upload image to database through uri. for that i am using HttpClient class. But it shows path too long exception.(because i convert the image to base64 string and upload it). I tried to insert through WebClient class but unfortunately WebClient class is not available in uwp. so how do i upload the image through uri??
Code
public async void Upload()
{
var url1 = "http://www.example.com/upload.php";
var values1 = new List<KeyValuePair<String, String>>
{
new KeyValuePair<string, string>("Date", x.Date.ToString()),
new KeyValuePair<string, string>("Bill_Image", x.Bill_Image.ToString()),
};
HttpClient client1 = new HttpClient();
HttpResponseMessage response1 = new HttpResponseMessage();
try
{
response1 = await client1.PostAsync(url1,new FormUrlEncodedContent(values1));
if (response1.IsSuccessStatusCode)
{
var dialog = new MessageDialog("Successfully Added");
await dialog.ShowAsync();
}
else
{
// problems handling here
}
}
catch (Exception exc)
{
Debug.WriteLine(exc.ToString());
}
}