public void DragFileHolder_ondrop(Event evt) { jF(".DragFileHolder").removeClass("DragFileHolder_Hover"); SharpKit.Html.fileapi.File file = null; eval(@" if(evt.dataTransfer.files != null && evt.dataTransfer.files.length > 0) file = evt.dataTransfer.files[0]; "); this.SendFileData(file, this.ViewModel.GuidKey); }
//---------------------------------------------------------------------------------------------------- private void SendFileData(SharpKit.Html.fileapi.File file, string guidKey) { if (file == null) { alert("File was not attached."); return; } var arr = file.name.split("."); var ext = arr[arr.length - 1].toLowerCase().trim(); if (ext != "xlsx") { alert("Please attach an Excel file in the .xlsx format."); return; } var progress = jF(".ProgressControl"); var thisObj = this; eval(@" var formData = new FormData(); formData.append('file', file); var xhr = new XMLHttpRequest(); xhr.open('POST', 'ASPdatabase.NET.aspx?Upload=Excel&Key=" + guidKey + @"&TableId=" + this.ViewModel.GridRequest.Id + @"'); progress[0].value = 0; progress.show(); xhr.upload.onprogress = function (event) { if (event.lengthComputable) { var complete = (event.loaded / event.total * 100 | 0); progress[0].value = progress.innerHTML = complete; } }; xhr.onload = function () { progress[0].value = progress.innerHTML = 100; if(xhr.status == 200) thisObj.UploadComplete(); else alert('An error occurred during upload. \nxhr.status: ' + xhr.status); }; xhr.send(formData); "); jF(".TwoOptionTable").hide(); jF(".SendingFile").show(); }