阅读背景:

ASP.NET 保存图片

来源:互联网 
 
 
  HttpPostedFileBase logo = Request.Files["txtlogo"];//从前台获取图片属性
     if (logo.ContentLength != 0)
     {
        string name = logo.FileName;
        //获取后缀名  ToLower转换成小写
        string logojpg = Path.GetExtension(name).ToLower();
        if (logojpg != ".jpg" && logojpg != ".png" && logo.ContentLength>0)
        {
            return Json(new { state = false });
        }
        //获取路径
        string path = Server.MapPath("../imgs/");
        //生成新的文件名
        string guid = System.Guid.NewGuid().ToString();
        string newName = guid + logojpg;
        //保存文件
        logo.SaveAs(path + newName);
        model.Logo = newName;
     

}  HttpPostedFileBase logo = Request.Files["t



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: