So i am currently working with js ajax to try to get the user of my Application to upload a Directory and then send the Directory/Files to Server side with ajax.
This is in Visual Studio and im using Chrome, so far i got some Illegal Invocation exceptions or it works but i receive "null" on the Server Side
My Form
<div class="form-group">
@Html.Label("Directory", "Directory", htmlAttributes: new { @class = "control-label col-xs-6" })
<div class="col-xs-30">
<input type="file" name="Directory" id="Directory" style="height: 1.7em; width:100%" webkitdirectory directory multiple />
</div>
<button onclick="myFunction()">Click me</button>
</div>
Javascript
<script>
function myFunction() {
let files = document.getElementById('Directory').files;
$.ajax({
url: "@Url.Action("RecursiveDirectory", "UploadDirectory")",
cache: false,
method: 'GET',
data : { files},
success : function(result) {
alert(result.success);
}
});
}
</script>
Server side
public JsonResult RecursiveDirectory(string data)
{
ContentResult contentResult = new ContentResult()
{
//Content = JsonConvert.SerializeObject(s)
};
return Json(null, JsonRequestBehavior.AllowGet);
}
Illegal Invocation is what i often got or just null on server side.