Ejemplo n.º 1
0
        public ActionResult Index(int id, UploadFile model)//idmaster
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            byte[] uploadFile = new byte[model.File.InputStream.Length];
            model.File.InputStream.Read(uploadFile, 0, uploadFile.Length);

            string fileFolder = Server.MapPath("~/Files");
            if (!Directory.Exists(fileFolder))
            {
                Directory.CreateDirectory(fileFolder);
            }
            string folderMaster = id.ToString().PadLeft(10, '0');
            string folder = Server.MapPath("~/Files/" + folderMaster);
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            string file = Path.Combine(folder, Guid.NewGuid().ToString() + "." + Path.GetExtension(model.File.FileName));
            System.IO.File.WriteAllBytes(file, uploadFile);

            return Content("File Uploaded.");
        }
Ejemplo n.º 2
0
 public ActionResult Download(int id)
 {
     FASTrack.ViewModel.UploadFile file = new UploadFile();
     file.Id = id;
     return View(file);
 }
Ejemplo n.º 3
0
 public ActionResult Index(int id)//idmaster
 {
     var model = new UploadFile();
     model.Id = id;
     return View(model);
 }