I have some issue for my c# code for upload some file...in controller file detect null.
My html code
@using (Html.BeginForm("Index", "UploadHistory",FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input type="file" name="uploadFile" id="uploadFile" />
<input type="submit" value="Upload File" id="btnSubmit" />
}
and this code for my controller
[HttpPost]
public ActionResult Index(HttpPostedFileBase uploadFile)
{
// Verify that the user selected a file
if (uploadFile != null && uploadFile.ContentLength > 0)
{
// extract only the fielname
var fileName = Path.GetFileName(uploadFile.FileName);
// store the file inside ~/App_Data/uploads folder
var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
uploadFile.SaveAs(path);
}
// redirect back to the index action to show the form once again
return RedirectToAction("Index");
}
Any ideas why my upload file detect null?? i use C# mvc 4 and razor thank you.
[SOLVED] Just error in javascript method post.