Мой HTML-файл index.cshtml выглядит следующим образом
<html>
<head>
</head>
<body>
<form method="post">
<input type="file" name="myfile" id="myfile" />
<input type="submit" value="Upload" />
</form>
</body>
</html>
Мой контроллер выглядит так
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(HttpPostedFileBase myfile)
{
string currentdir = Directory.GetCurrentDirectory();
myfile.SaveAs(currentdir + "\\" + myfile.FileName);
return View();
}
}
И ошибка произошла, когда я разместил файл.Он сказал, что объект myfile был нулевым.Пожалуйста, помогите исправить это.Большое спасибо!