コード例 #1
0
ファイル: PdfController.cs プロジェクト: shroshri/churchweb
        public ActionResult Edit(Pdtable pdtable, HttpPostedFileBase file)
        {
            if (ModelState.IsValid && file != null && file.ContentLength > 0)
            {
                churchdbEntities4 db = new churchdbEntities4();
                string PdfName = System.IO.Path.GetFileName(file.FileName);
                string physicalPath = Server.MapPath("~/Puploads/" + PdfName);

                // save image in folder
                file.SaveAs(physicalPath);
                pdtable.pname = Request.Form["pname"];
                pdtable.pdate = Request.Form["pdate"];
                pdtable.pdfdoc = "~/Puploads/" + PdfName;
                db.Entry(pdtable).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(pdtable);
        }