Hi !!
I am using RadUpload to upload single video file at a time. The code in aspx file is
on clicking "BtnUpload" I have logic to save file on server directory.
aspx.cs file is :
My web.config file is :
The problem is I want to cancel the upload process of current file (during uploading process is going on )on clicking "Cancel" button shown in Progressarea. How can be it possible?. At present when user clicks on "cancel" button, it just closes the uploading progress dialog, but still physical file gets uploaded on serverside. It should not be uploaded alt all.
I am using RadUpload to upload single video file at a time. The code in aspx file is
<telerik:RadScriptBlock ID=
"RadScriptBlock1"
runat=
"server"
>
<script type=
"text/javascript"
>
function
checkFileExists() {
var
count = 0;
var
upld = $find(
'<%= RadUpload1.ClientID %>'
);
var
input = $find(
'<%= RadUpload1.ClientID %>'
).getFileInputs();
var
fileName = input[0].value.toLowerCase();
var
allowOverWriteFile =
true
;
//To check whether the selected file is with mp4 extension or not
if
(upld.isExtensionValid(fileName) ==
false
) {
alert(
"You are allowed to upload only MP4 files. Kindly select the MP4 video and upload again."
);
return
false
;
}
//To confirm overwrite
count = document.getElementById(
'<%= txtUrl.ClientID %>'
).options.length;
for
(
var
i = 0; i < count; i++) {
if
(fileName == document.getElementById(
'<%= txtUrl.ClientID %>'
).options[i].value.toLowerCase()) {
allowOverWriteFile = confirm(
"This file is already exists. Are you sure want to overwrite it?"
);
return
allowOverWriteFile;
}
}
return
true
;
}
</script>
</telerik:RadScriptBlock>
<telerik:RadProgressManager ID=
"RadProgressManager1"
runat=
"server"
Width=
"245px"
/>
<telerik:RadProgressArea ID=
"RadProgressArea1"
runat=
"server"
ProgressIndicators=
"TotalProgressBar,CurrentFileName,RequestSize,TransferSpeed"
Skin=
"Default"
Width=
"245px"
DisplayCancelButton=
"true"
>
</telerik:RadProgressArea>
<telerik:RadUpload ID=
"RadUpload1"
runat=
"server"
OverwriteExistingFiles=
"true"
ControlObjectsVisibility=
"None"
InitialFileInputsCount=
"1"
AllowedFileExtensions=
".mp4"
Width=
"100px"
allowedmimetypes=
"application/mp4,video/mp4"
>
</telerik:RadUpload>
<asp:Button ID=
"BtnUpload"
runat=
"server"
Text=
"Upload"
OnClientClick=
"return checkFileExists()"
onclick=
"BtnUpload_Click"
/>
on clicking "BtnUpload" I have logic to save file on server directory.
aspx.cs file is :
protected
void
BtnUpload_Click(
object
sender, EventArgs e)
{
//int counter = 0;
string
targetFolder =
string
.Empty;
string
targetFileNameAndPath =
string
.Empty;
string
targetFileNameWithExtension =
string
.Empty;
string
targetFileNameWithoutExtension =
string
.Empty;
string
tempFilename =
string
.Empty;
if
(RadUpload1.UploadedFiles.Count > 0)
{
if
(RadUpload1.InvalidFiles.Count > 0)
{
labelInvalidResults.Visible =
true
;
}
else
{
labelInvalidResults.Visible =
false
;
targetFolder = Server.MapPath(ResolveUrl(
"~/directoryName/"
));
targetFileNameAndPath = Path.Combine(targetFolder, RadUpload1.UploadedFiles[0].GetNameWithoutExtension() + RadUpload1.UploadedFiles[0].GetExtension());
targetFileNameWithExtension = RadUpload1.UploadedFiles[0].GetNameWithoutExtension() + RadUpload1.UploadedFiles[0].GetExtension();
targetFileNameWithoutExtension = RadUpload1.UploadedFiles[0].GetNameWithoutExtension();
tempFilename = targetFileNameWithoutExtension.Replace(
"_"
,
" "
);
RadUpload1.UploadedFiles[0].SaveAs(targetFileNameAndPath);
Thread uploadVideoThread =
new
Thread(() => convertVideoFile(targetFileNameAndPath, targetFileNameWithExtension, targetFileNameWithoutExtension));
uploadVideoThread.Start();
}
}
}
My web.config file is :
<
system.web
>
<
httpModules
>
<
add
name
=
"RadUploadModule"
type
=
"Telerik.Web.UI.RadUploadHttpModule"
/>
</
httpModules
>
<
httpRuntime
maxRequestLength
=
"102400"
executionTimeout
=
"3600"
/>
</
system.web
>
<
system.webServer
>
<
modules
>
<
add
name
=
"RadUploadModule"
preCondition
=
"integratedMode"
type
=
"Telerik.Web.UI.RadUploadHttpModule"
/>
</
modules
>
<
handlers
>
<
add
name
=
"Telerik_RadUploadProgressHandler_ashx"
verb
=
"*"
preCondition
=
"integratedMode"
path
=
"Telerik.RadUploadProgressHandler.ashx"
type
=
"Telerik.Web.UI.RadUploadProgressHandler"
/>
</
handlers
>
</
system.webServer
>
The problem is I want to cancel the upload process of current file (during uploading process is going on )on clicking "Cancel" button shown in Progressarea. How can be it possible?. At present when user clicks on "cancel" button, it just closes the uploading progress dialog, but still physical file gets uploaded on serverside. It should not be uploaded alt all.