Advertisement
Guest User

UploadController

a guest
Oct 21st, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.Mvc;
  7.  
  8. namespace UploadFiles.Controllers
  9. {
  10.     public class UploadController : Controller
  11.     {
  12.         // GET: Upload
  13.         public ActionResult Index()
  14.         {
  15.             return View();
  16.         }
  17.         [HttpPost]
  18.         public ActionResult Upload(HttpPostedFileBase file)
  19.         {
  20.             if (file != null && file.ContentLength > 0)
  21.             {
  22.                 var fileName = Path.GetFileName(file.FileName);
  23.                 var path = Path.Combine(Server.MapPath("~/Images/"), fileName);
  24.                 file.SaveAs(path);
  25.             }
  26.  
  27.             return RedirectToAction("UploadDocument");
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement