asp.net mvc 上传图片流存服务器

 1             foreach (var file in Request.Files)
 2                     {
 3                         var pathSrc = System.Web.HttpContext.Current.Server.MapPath("~/Upload/" + dt + "." + file.Name.Split('.')[1]);
 4                         using (FileStream fs = new FileStream(pathSrc, FileMode.Create))
 5                         {
 6                             file.Value.CopyTo(fs);
 7                         }
 8 
 9                         return Response.AsJson(new { img = "http://" + Request.Url.HostName + "/Upload/" + dt + "." + file.Name.Split('.')[1] });
10                     }

 

posted on 2016-05-25 11:17  算顺网  阅读(1226)  评论(0编辑  收藏  举报

导航