Ejemplo n.º 1
0
        public ActionResult SavePortfolioWork(Work aObj)
        {
            if (System.Web.HttpContext.Current.Request.Files.AllKeys.Any())
            {
                var    pic = System.Web.HttpContext.Current.Request.Files["MyImages"];
                var    originalFilename = Path.GetFileName(pic.FileName);
                string fileId           = Guid.NewGuid().ToString().Replace("-", "");
                //  string userId = GetUserId(); // Function to get user id based on your schema
                var savePath = @"~/Upload/Image/";

                var path = Path.Combine(Server.MapPath("~/Upload/Image/"), "1", originalFilename);
                // pic.SaveAs(path);
                //data.HomeImageLink = path;

                var physicalPath = Path.Combine(Server.MapPath(savePath), originalFilename);
                pic.SaveAs(physicalPath);

                aObj.ImageLink = savePath.Replace("~", "..") + "/" + originalFilename;
            }
            var aData = _aManager.SavePortfolioWork(aObj);

            return(Json(new { success = aData.Status, aData }, JsonRequestBehavior.AllowGet));
        }