User-1343662111 posted
Hey,
I'm trying to upload videos to my Server via 3 Pages. The first page should contain the file upload and the title of the video and the second page
contains more information about the video to fill out. The third page is just a confirmation that the video was uploaded.
My problem is that i need to access the file i uploaded on the first page to access it's name after i sent the form on the second page. Transfering the data from
page 1 to 2 works perfectly fine but when i go to 3 all data from 1 gets deleted and i can only access the data of 2.
//Page 1
public ViewResult Upload()
{
var viewModel = new UploadViewModel();
return View("Upload", viewModel);
}
//Page2
[HttpPost]
public ActionResult Upload(UploadViewModel model)
{
if (model.File != null)
{
model.Filename = model.File.FileName;
string internPath = "Media\\" + model.File.FileName + "ordner";
string filePath = Server.MapPath("~") + internPath;
Directory.CreateDirectory(filePath);
model.File.SaveAs(filePath + @"\Video.mp4");
model.Thumbnails = ThumbnailConverter.GetImage(filePath + @"\Video.mp4", filePath, internPath);
}
return View("Upload", model);
}
//Page3
[HttpPost]
public ActionResult UploadFinished(UploadViewModel model)
{
int thumbnailIndex = 0;
string est = Request.Form["thumbString"];
if (Int32.TryParse(est, out thumbnailIndex))
{
if (thumbnailIndex < 0)
{
string internPath = "Media\\" + model.File.FileName + "ordner";
string filePath = Server.MapPath("~") + internPath;
Directory.CreateDirectory(filePath);
model.File.SaveAs(filePath + @"\thumbnail.png");
model.ThumbnailPath = internPath + @"\thumbnail.png";
}
else
{
model.ThumbnailPath = model.Thumbnails[thumbnailIndex];
}
}
I thought handing over the viewmodel the data is saved in would do the trick but it seems like in the .cshtml form a new viewmodel gets created and it just uses the values of the Model i created the view with.
How do i make the form to remember the File reference and pass it on in the form without using another textbox (type file)?