I'm having problems with an form.
I need to submit a form with ajax with fileinput in the form. In this form, I use the plugin with fileinput. This is the website
Here is my code:
<link href="~/Content/Plugin/bootstrap-fileinput-master/css/fileinput.min.css" rel="stylesheet" />
<script src="~/Content/Plugin/bootstrap-fileinput-master/js/fileinput.min.js"></script>
<script src="~/Content/Plugin/bootstrap-fileinput-master/js/fileinput_locale_zh.js"></script>
@using (Ajax.BeginForm(null, null, new AjaxOptions(){
HttpMethod = "post",Url = Url.Action("Upload", "WorkItem"),
InsertionMode = InsertionMode.Replace, LoadingElementDuration = 2000,
OnSuccess = "completed" },
new { role = "form", enctype = "multipart/form-data" }))
{
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">TITLE</span>
<input type="text" name="Descr" class="form-control" aria-describedby="basic-addon1">
</div>
<div class="m-b-5"></div>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">POINT</span>
<input type="text" name="Point" class="form-control" aria-describedby="basic-addon1">
</div>
<div class="m-b-5"></div>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">DESCR</span>
<input type="text" name="Descr" class="form-control" aria-describedby="basic-addon1">
</div>
<div class="m-b-5"></div>
<input id="file-0a" name="file" class="file" type="file" data-min-file-count="1">
<br />
<button type="submit" class="btn btn-primary">Submit</button>
<button type="reset" class="btn btn-default">Reset</button>
}
When I click the submit button, no file can be accepted. What is going wrong?
Ajax.BeginForm()Either upload it using the features of the plugin your using, or if you want to upload the form values including the file, refer this answer