コード例 #1
0
        public ActionResult CatalogSetting(HttpPostedFileBase upl)
        {
            if (ModelState.IsValid)
            {
                if (upl != null && CheckContentdocument.isdocoment(upl))
                {
                    string filename = Guid.NewGuid() + Path.GetExtension(upl.FileName);
                    upl.SaveAs(Server.MapPath("/img/") + filename);
                    xml.SavetoXml("siteSetting/Catalog", "/img/" + filename);
                    ViewBag.Erorr = false;
                }
                else
                {
                    ViewBag.Erorr = true;
                }
            }

            ViewBag.catalog = xml.loadline("siteSetting/Catalog");
            return(View());
        }
コード例 #2
0
 public ActionResult ProductAttachFile(int ProductID, string FileTitle, HttpPostedFileBase Fileupl)
 {
     if (Fileupl != null && CheckContentdocument.isdocoment(Fileupl))
     {
         string filename = Guid.NewGuid() + Path.GetExtension(Fileupl.FileName);
         Fileupl.SaveAs(Server.MapPath("/img/Products/AttachFiles/") + filename);
         db.ProductAttachFiles.Add(new ProductAttachFile()
         {
             AttachFileTitle = FileTitle,
             FileName        = filename,
             ProductID       = ProductID
         });
         db.SaveChanges();
     }
     else
     {
         ViewBag.errorpage = true;
     }
     ViewBag.ProductID   = ProductID;
     ViewBag.ProductName = db.Products.Find(ProductID).Title;
     return(View(db.ProductAttachFiles.Where(p => p.ProductID == ProductID)));
 }