Hi,
I am using kendo upload control and I need to upload zip file through only if zip file has only one file inside it other wise i needed to fail the upload. OnSuccess event of upload I am calling controller action to add validations for the upload file. How can I send file itself through Ajax to controller action so that i can extract zip file on server side and fail the upload if zip has more than 1 file inside it.
@(Html.Kendo().Upload()
.Name("files").ShowFileList(false)
.Async(a => a.AutoUpload(false)
.Save("UploadSingleDocument", "Upload")
)
.Multiple(false)
.Events(events => events
.Select("attachClickHandler")
.Upload("OnUpload").Success("OnSuccess").Error("onError"))
)
Below is my javascript code. e.files[0] is always returning null.
$.ajax({
url: ('@Url.Action("ValidateDocumentExtension", "Upload")'),
contentType: "application/json",
async: true,
type: "POST",
data: JSON.stringify({files:e.files[0], fieldlst: webFormFields, fileName: document.getElementById("DocumentName").value }),
success: function(data) {
if (data === 'False') {
showNotification("Upload Document", "Invalid Document Extension", "error");
flagUpload = false;
} else if (data === 'True') {
flagUpload = true;
if ($("div.k-notification-error").Exists()) {
$("div.k-notification-error").hide();
}
if ($("div.k-notification-info").Exists()) {
$("div.k-notification-info").hide();
}
}
}
});