asp.net mvc 4 - how to upload file asynchronously in mvc with example without loading entire page -
asp.net mvc 4 - how to upload file asynchronously in mvc with example without loading entire page -
var formdata; formdata = new formdata(); var fileinput = document.getelementbyid('filetouploadinproposal'); //iterating through each files selected in fileinput (i = 0; < fileinput.fi.length; i++) { //appending each file formdata object formdata.append(fileinput.files[i].name, fileinput.files[i]); } //creating xmlhttprequest , sending var xhr = new xmlhttprequest(); xhr.open('post', "/contract/uploadproposaldocument/"); xhr.send(""); xhr.onreadystatechange = function () { debugger; if (xhr.readystate == 4 && xhr.status == 200) { $("#filetouploadinproposal").val("") alert(xhr.responsetext); } } homecoming false;
in client side formdata not accepting , fileinput.files.length not accepting
you can utilize jquery plugin utilize asp.net mvc upload file via ajax:
http://powerdotnetcore.com/asp-net-mvc/asp-net-mvc-simple-ajax-file-upload-using-jquery
or can refer tutorial made , used in scenarios, uses iframe upload file:
http://developmentpassion.blogspot.com/2013/08/aspnet-mvc-ajax-file-uploading-using.html
asp.net-mvc-4
Comments
Post a Comment