0
Das ist meine Modellklasse:HttpPostedFileBase Erste null, wenn ich Fileupload-Steuerelement in MVC verwenden
public class FileUploadModel
{
public HttpPostedFileBase File { get; set; }
}
Diese Meine Ansicht ist:
@using VidesExample.Models
@model FileUploadModel
@{
ViewBag.Title = "FileUpload";
}
<h2>FileUpload</h2>
@using (Html.BeginForm("FileUpload","Sample"))
{
@Html.TextBoxFor(model=>model.File,new { type="file"})
<input type="submit" value="Upload" />
}
Und das ist mein Controller:
public ActionResult FileUpload()
{
return View();
}
[HttpPost]
public ActionResult FileUpload(FileUploadModel obj)
{
var file=obj.File;
// if (video.File.ContentLength <= 0) return null;
// var fileName = Path.GetFileName(video.File.FileName);
// if (fileName == null) return null;
// var path = Path.Combine(Server.MapPath("~/Videos"), fileName);
// video.File.SaveAs(path);
//// return fileName;
return View();
}
Wenn ich versuche, die Datei zu erhalten, wird der Nullwert angezeigt. und wie man die Videos mit Mvc anzeigt und speichert.
Seine working.Thank Sie – sadasiva