RadUpload cancel process of current uploading file

Thread is closed for posting
2 posts, 0 answers
  1. Eric
    Eric avatar
    1 posts
    Member since:
    Jul 2010

    Posted 30 Jan 2012 Link to this post

    Hi !!

    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;
    <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:RadUpload ID="RadUpload1" runat="server" OverwriteExistingFiles="true" ControlObjectsVisibility="None" InitialFileInputsCount="1" AllowedFileExtensions=".mp4" Width="100px" allowedmimetypes="application/mp4,video/mp4">
    <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;
                        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("_", " ");
                        Thread uploadVideoThread = new Thread(() => convertVideoFile(targetFileNameAndPath, targetFileNameWithExtension, targetFileNameWithoutExtension));

    My web.config file is :

            <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule" />
            <httpRuntime maxRequestLength="102400" executionTimeout="3600" />
                    <add name="RadUploadModule" preCondition="integratedMode" type="Telerik.Web.UI.RadUploadHttpModule" />
            <add name="Telerik_RadUploadProgressHandler_ashx" verb="*" preCondition="integratedMode" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" />

    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.

  2. Bozhidar
    Bozhidar avatar
    1146 posts

    Posted 30 Jan 2012 Link to this post

    Hi Eric,

    If you want to stop the proccess of uploading, you will have to use RadAsyncUpload. You can check out it's functionality and how you can use a RadProgressArea with it in the following demo:
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top