I use a custom file uploader and need to pass file parameter with the name of files[]. Because it does not make any sense and the file data is sent by this default name of the file uploader. However, I cannot use the same parameter name in the Controller. So, how can I use files[] as the name parameter of input control?
View:
<input type="file" name="files[]" id="filer_input" multiple="multiple" >
<script>
function create(event) {
event.preventDefault();
var formdata = new FormData($('#frmCreate').get(0));
$.ajax({
type: "POST",
url: '@Url.Action("Create", "Experiment")',
cache: false,
dataType: "json",
data: formdata,
processData: false,
contentType: false
});
};
</script>
Controller:
public JsonResult Insert([Bind(Exclude = null)] ViewModel model,
IEnumerable<HttpPostedFileBase> files)
{
//code removed for brevity
}
Any idea?