string boundary = string.Format("----WebKitFormBoundary{0}", DateTime.Now.Ticks.ToString("x")); MultipartFormDataContent content = new MultipartFormDataContent(boundary); content.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data; boundary=" + boundary); string fileName = Path.GetFileName(picPath); using FileStream fStream = File.Open(picPath, FileMode.Open, FileAccess.Read); content.Add(new StreamContent(fStream, (int)fStream.Length), "file", fileName); using HttpClient client = new HttpClient(); HttpResponseMessage response = client.PostAsync(url, content).Result; if (response.IsSuccessStatusCode) ....
标签:string,form,content,multipart,new,boundary,httpclient From: https://www.cnblogs.com/xuejianxiyang/p/17752029.html