/// <summary> /// 用户头像上传 /// 未完成 不能保存图片到文件夹 因为本地文件没有权限是本机的用户角色问题 /// </summary> /// <returns></returns> public ActionResult UploadPic() { IdentityTicket identity = IdentityManager.GetIdentFromAll(); if (identity == null) { return(DataProcess.Failure("请先登入").ToMvcJson()); } HttpPostedFileBase file = Request.Files["file"]; string filepath = AppDomain.CurrentDomain.BaseDirectory + "HeadImage";//存放文档图片的路径 string filename = Common.CreateImageFileName() + ".jpg"; string filepathclone = Path.Combine(filepath, Path.GetFileName(filename)); if (!System.IO.File.Exists(filepath)) { Directory.CreateDirectory(filepath); } file.SaveAs(filepathclone); //保存路径到数据库 DataResult dp = UserOperateContract.SaveImage(identity.UserId, "../HeadImage/" + filename); if (dp.Success) { return(DataProcess.Success("../HeadImage/" + filename).ToMvcJson()); } else { return(dp.ToMvcJson()); } }