I am uploading a large file using MVC.I am able to upload a large file but after chunking, merging and deleting not seen any successful message. Here is my code.
Here I clicked upload button after loading gif animated
$('#btnUpload').click(function () {
var url = '@Url.Action("PostMethod", "Home")';
$("#divLoading").show();
UploadFile($('#uploadFile')[0].files);
$.post(url, null,
function (data) {
// $("#PID")[0].innerHTML = data;
$("#divLoading").hide();
//alert("completed");
});
}
)
function UploadFileChunk(Chunk, FileName)
{
var FD = new FormData();
FD.append('file', Chunk, FileName);
$.ajax({
type: "POST",
url: 'http://localhost:xxxx/Home/UploadFile/',
contentType: false,
processData: false,
data: FD
});
}
function UploadFile(TargetFile)
{
}
Below you can see Home controller.cs file
[HttpPost]
public HttpResponseMessage UploadFile()
{
try
{
if (System.IO.File.Exists(path))
System.IO.File.Delete(path);
using (var fileStream = System.IO.File.Create(path))
{
stream.CopyTo(fileStream);
}
// Once the file part is saved, see if we have enough to merge it
Shared.Utils UT = new Shared.Utils();
UT.MergeFile(path);
}
catch (IOException ex)
{
// handle
}
return new HttpResponseMessage()
{
StatusCode = System.Net.HttpStatusCode.OK,
Content = new StringContent("File uploaded.")
};
}
Kindly let me know where should I add completed message.