I have a file upload button which can upload multiple files. I want to store these files on to a folder using javascript and send these file details from view to the controller. I am doing mvc 4 razor app. Am new to MVC. I know that it can be done with json and ajax post methods. But dont know how to use this.
<script type="text/javascript">
var fileNames = [];
function handleFileUpload(evt) {
evt.stopPropagation();
evt.preventDefault();
var files = document.getElementById('file1').files;
for (var i = 0; files[i]; i++) {
fileNames.push(files[i]);
}
}
$(function () {
$("#btnSubmit").click(function () {
$.post("@Url.Action("FileDetails")", { filename: JSON.stringify(fileNames) }, "json");
});
});
</script>
This was what I have done so far.