Example #1
0
        // GET: UploadFile
        public ActionResult Upload(HttpPostedFileBase file)
        {
            DataTable tbl = new DataTable();

            ViewBag.Success = "";
            ViewBag.Error   = "";
            try
            {
                string fileLocation = Server.MapPath("~/App_Data/uploads/" + file.FileName);
                file.SaveAs(fileLocation);
                ViewBag.Success = "File Uploaded successfully to the following location: " + fileLocation;
                tbl             = UploadFile.ProcessUpload(fileLocation);
            }
            catch (Exception ex)
            {
                ViewBag.Success = "";
                ViewBag.Error   = "Error: " + ex.Message;
            }

            return(View(tbl));
        }