Hello,
I'm building a multi video uploader using "RadAsyncUpload" control.
for each video the user will be asked to fill its title. after he had selected all the videos with their titles he will press submit.
The page will only submit the files after all of them have been uploaded.
On the server side, after the submission each file directory will be change and a new record in the database will be added.
My question is:
Since the upload process can take a lot of time ,and in the event of a connection lost, or closing the browser by mistake
the user will have to upload all files again.
I was wondering if it is possible to call a server side function to preforme the file logging and manupuletion for each completed video without stopping the upload process?
this is a snippet of my code for example:
thank you
oren
I'm building a multi video uploader using "RadAsyncUpload" control.
for each video the user will be asked to fill its title. after he had selected all the videos with their titles he will press submit.
The page will only submit the files after all of them have been uploaded.
On the server side, after the submission each file directory will be change and a new record in the database will be added.
My question is:
Since the upload process can take a lot of time ,and in the event of a connection lost, or closing the browser by mistake
the user will have to upload all files again.
I was wondering if it is possible to call a server side function to preforme the file logging and manupuletion for each completed video without stopping the upload process?
this is a snippet of my code for example:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestPage.aspx.cs" Inherits="TestPage" %>
<!DOCTYPE html>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
style
=
"background-color: white"
id
=
"test-div"
>
<
asp:ScriptManager
ID
=
"ScriptManagerMain"
runat
=
"server"
>
<
Scripts
>
<
asp:ScriptReference
Path
=
"~/Script/jquery-1.9.1.min.js"
/>
<
asp:ScriptReference
Path
=
"~/Script/jquery-migrate.js"
/>
<
asp:ScriptReference
Path
=
"~/Script/ValidationEngineLibrary/jquery.validationEngine.js"
/>
<
asp:ScriptReference
Path
=
"~/Script/ValidationEngineLibrary/jquery.validationEngine-en.js"
/>
</
Scripts
>
</
asp:ScriptManager
>
<
telerik:RadAsyncUpload
runat
=
"server"
ID
=
"RadAsyncUpload1"
ClientIDMode
=
"Static"
HideFileInput
=
"true"
OnClientFilesUploaded
=
"fileUploaded"
OnClientFileSelected
=
"addFileTitle"
MultipleFileSelection
=
"Automatic"
MaxFileInputsCount
=
"10"
></
telerik:RadAsyncUpload
>
<
asp:Button
ID
=
"btnSubmit"
runat
=
"server"
Text
=
"Submit"
OnClientClick
=
"return submitPage();"
OnClick
=
"btnSubmit_Click"
/>
<
span
id
=
"uploading-msg"
></
span
>
<
input
type
=
"button"
runat
=
"server"
value
=
"clearAll"
onclick
=
"clearAll()"
/>
<
asp:Label
runat
=
"server"
ID
=
"updateInfo"
></
asp:Label
>
</
div
>
<
telerik:RadScriptBlock
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
var submitPressed = false;
function clearAll() {
$("#RadAsyncUpload1").find("input[name=RowRemove]").each(function () {
$(this).click();
});
}
function addFileTitle(radAsyncUpload, args) {
var $row = $telerik.$(args.get_row());
var inputName = radAsyncUpload.getAdditionalFieldID("TextBox");
var inputType = "text";
var inputID = inputName;
var input = createInput(inputType, inputID, inputName);
var label = createLabel(inputID);
$row.append("<
br
/>");
$row.append(label);
//Add required validation
$(input).addClass("validate[required,custom[movieTitle]]");
$row.append(input);
}
function createInput(inputType, inputID, inputName) {
var input = '<
input
type
=
"' + inputType + '"
id
=
"' + inputID + '"
name
=
"' + inputName + '"
/>';
return input;
}
function createLabel(forArrt) {
var label = '<
label
for
=
' + forArrt + '
>File info: </
label
>';
return label;
}
function submitPage() {
$('#form1').validationEngine({ maxErrorsPerField: "1", binded: false, scroll: false });
var valid = $('#form1').validationEngine('validate');
//Check file uploads
if (valid == false)
return false;
if (!isAllUploadCompleted()) {
$("#<%=btnSubmit.ClientID%>").hide();
$("#uploading-msg").text("Uploading");
setInterval(function () { $("#uploading-msg").blink(); }, 1500);
$("#test-div").blockElement();
submitPressed = true;
return false;
}
return true;
}
function fileUploaded() {
if(submitPressed && isAllUploadCompleted())
fireSubmit();
}
function isAllUploadCompleted() {
var $ = $telerik.$;
//finds all file uploads that are currently in progress
var uploadingRows = $(".RadAsyncUpload").find(".ruUploadProgress");
//iterates and checks is there any file uploads that are successfully completed or failed and if yes - pop-up an alert box and prevent page submitting
for (var i = 0; i <
uploadingRows.length
; i++) {
if (!$(uploadingRows[i]).hasClass("ruUploadCancelled") && !$(uploadingRows[i]).hasClass("ruUploadFailure") && !$(uploadingRows[i]).hasClass("ruUploadSuccess")) {
return false;
}
}
return true;
}
function fireSubmit() {
document.getElementById("<%=btnSubmit.ClientID%>").removeAttribute("onclick");
document.getElementById("<%=btnSubmit.ClientID%>").click();
}
</
script
>
</
telerik:RadScriptBlock
>
</
form
>
</
body
>
</
html
>
thank you
oren