//上传图片到服务器 HttpClient client = new HttpClient(); MultipartFormDataContent form = new MultipartFormDataContent();//表单 StreamContent fileContent = new StreamContent(stream);//图片stream fileContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data"); fileContent.Headers.ContentDisposition.FileName = System.DateTime.Now.ToString("yyyMMddHHmmss") + new Random().Next(1000, 9999) + ".jpg"; form.Add(fileContent); string url = "http://" + authorizeModel.url + "/Login/UploadFile";//接口 HttpResponseMessage res = await client.PostAsync(url, form); var result = await res.Content.ReadAsStringAsync();