public static string PostJsonData(string url, Dictionary<string, string> dic, string imgfile)
{
string str = "";
try
{
HttpClient client = new HttpClient();
var postContent = new MultipartFormDataContent();
string boundary = string.Format("--{0}", DateTime.Now.Ticks.ToString("x"));
postContent.Headers.Add("ContentType", $"multipart/form-data, boundary={boundary}");
string image_file_Type="faceImage";
postContent.Add(new ByteArrayContent(File.ReadAllBytes(imgfile)), image_file_Type, imgfile);
foreach (var key in dic.Keys)
{
postContent.Add(new StringContent(dic[key].ToString()), key);
}
HttpResponseMessage response = client.PostAsync(url, postContent).Result;
str = response.Content.ReadAsStringAsync().Result;
}
catch (Exception ex)
{
Log.Print("PostJsonData:" + ex.ToString());
}
return str;
}