public IActionResult Upload(IList <IFormFile> files) { foreach (var file in files) { var header = ContentDispositionHeaderValue.Parse(file.ContentDisposition); var fileName = header.FileName.ToString().Trim('"'); fileName = Path.GetFileName(fileName); var ms = new MemoryStream(); var stream = file.OpenReadStream(); stream.CopyTo(ms); var data = ms.ToArray(); stream.Close(); ms.Close(); var upload = new UploadedFile { FileName = fileName, ContentType = file.ContentType, Size = file.Length, TimeStamp = DateTime.Now, FileContent = data }; var backup = upload.DeepCopy(); // send upload file to main system // send backup to backup system } ViewBag.Message = $"{files.Count} file(s) uploaded successfully!"; return(View("Index")); }
public ActionResult Prototype() { IUploadedFile u = new UploadedFile(); u.Clone(); u.DeepCopy(); return(View()); }