Hi,
I have this javascript function which is to send the file to action result.
function fileChanged(e) { // Upload file - User select file/s
debugger;
var fileInput = $(e)[0];
var data = new FormData();
var token = $("input[name='__RequestVerificationToken']").val();
data.append('__RequestVerificationToken', token);
data.append('files', fileInput.files[0]);$.ajax({
type: "POST",
url: '@Url.Action("Upload", "Dashboard")',
contentType: false,
processData: false,
data: data,
success: function (result) {
if (result.result) {
}
else {
}
},
error: function () {
}
});
}And the Action in controller as below:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Upload(HttpPostedFileBase files)
{
// My Code
}Also in the View I added
}
@using (Html.BeginForm("Apply", "Dashboard", FormMethod.Post,
new
{
autocomplete = "off",
enctype = "multipart/form-data",
}))
{
@Html.AntiForgeryToken()but still I'm facing the error: The required anti-forgery form field "__RequestVerificationToken" is not present.
Please Help