Answers for "upload file controller"

0

upload file controller

public ActionResult UploadFile(HttpPostedFileBase filee)
        {
            try
            {
                if (filee.ContentLength > 0)
                {
                    string _FileName = Path.GetFileName(filee.FileName);
                    string _path = Path.Combine(Server.MapPath("~/UploadedFiles"), _FileName);
                    filee.SaveAs(_path);
                }
                ViewBag.Message = "File Uploaded Successfully!!";
                return View();
            }
            catch
            {
                ViewBag.Message = "File upload failed!!";
                return View();
            }
        }
Posted by: Guest on August-26-2021

Browse Popular Code Answers by Language