How can I POST <input type="file" id="uploadStudent" />
uploaded file to mvc controller in this scenario?
Javascript
$.ajax({
url: "/Home/CompleteAttendeeType",
contentType: "application/json;charset=utf-8",
dataType: "JSON",
type: "POST",
data: JSON.stringify({
//PostedFile: "I AM CONFUSED HOW TO UPLOAD?",
AttendeeType: 1,
LicenseNumber: $("#txtLicenseNumber").val(),
LicenseState: $("#txtLicenseState").val(),
SchoolName: $("#txtSchoolName").val(),
SchoolLocation: $("#txtSchoolLocation").val()
})
})
MVC
[HttpPost]
public JsonResult CompleteAttendeeType(CompleteAttendeeTypeRequest request)
{
return Json(string.Empty, JsonRequestBehavior.AllowGet);
}
public enum AttendeeType
{
Professional,
Student,
Owner,
Guest
}
public class CompleteAttendeeTypeRequest
{
public HttpPostedFile PostedFile { get; set; }
public AttendeeType AttendeeType { get; set; }
public string LicenseNumber { get; set; }
public string LicenseState { get; set; }
public string SchoolName { get; set; }
public string SchoolLocation { get; set; }
}