c:\Users\User\AppData\Local\Temp\Temporary ASP.NET Files\root\4d627a43\ab2fd5d9\App_Web_index.cshtml.32644dcb.zykik1o6.0.cs(36): error CS1001: Identifier expected
[HttpGet] public ActionResult Index() { return View(); } [HttpPost] public ActionResult Up(HttpPostedFileBase file) { if (ModelState.IsValid) { if (file == null) { ModelState.AddModelError("File", "Please Upload Your file"); } else if (file.ContentLength > 0) { int MaxContentLength = 1024 * 1024 * 3; //3 MB string[] AllowedFileExtensions = new string[] { ".jpg", ".gif", ".png", ".pdf" }; if (!AllowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.')))) { ModelState.AddModelError("File", "Please file of type: " + string.Join(", ", AllowedFileExtensions)); } else if (file.ContentLength > MaxContentLength) { ModelState.AddModelError("File", "Your file is too large, maximum allowed size is: " + MaxContentLength + " MB"); } else { var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/Upload"), fileName); file.SaveAs(path); ModelState.Clear(); ViewBag.Message = "File uploaded successfully. File path : ~/Upload/" + fileName; } } } return View(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)