예제 #1
0
        public ActionResult Uploads(string id)
        {
            UploadsIndexScreen screen = new UploadsIndexScreen();

            if (id.ToLower() == "save")
            {
                TryUpdateModel(screen);
                //User didn't select a file
                if (base.Request.Files.Count != 1 || string.IsNullOrEmpty(base.Request.Files[0].FileName))
                {
                    ModelState.AddModelError("fileUpload", "Please choose a file to upload.");
                    ViewData.Model = screen;
                    return View("Uploads/Index");
                }

                string fileName = base.Request.Files[0].FileName;
                if (System.IO.File.Exists(base.Server.MapPath("/Upload/") + fileName))
                {
                    LoggingHandler.Log("Upload file failed due to name", "Attempt to upload file that already exists with name " + fileName, "Error", "Home/Upload");
                    ModelState.AddModelError("fileUpload", "A file with that name already exists.  Please rename and try again.");
                    ViewData.Model = screen;
                    return View("Uploads/Index");
                }

                screen.SaveFile(Request.Files[0]);

                return RedirectToAction("Uploads");
            }

            ViewData.Model = screen;
            return View("Uploads/Index");
        }
예제 #2
0
        public ActionResult Uploads()
        {
            UploadsIndexScreen screen = new UploadsIndexScreen();
            ViewData.Model = screen;

            return View("Uploads/Index");
        }