/// 文件图片上传 /// </summary> /// <returns>成功上传返回上传后的文件名</returns> [HttpPost] public async Task<IHttpActionResult> UpLoadImageFiles() { var files = HttpContext.Current.Request.Files; if (files.AllKeys.Any()) { using (HttpClient client = new HttpClient()) { HttpContextBase HttpContext = (HttpContextBase)Request.Properties["MS_HttpContext"]; var request = new HttpRequestMessage(HttpMethod.Post, ConfigurationManager.AppSettings["SaveToImgaes"].ToString() + "/Upload/"); var content = new MultipartFormDataContent(); content.Add(new StreamContent(HttpContext.Request.Files[0].InputStream), "file", "file.jpg"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); var filenamestr = await response.Content.ReadAsStringAsync();//结果 } } return Ok(); }