RadAsyncUpload MaxFileInputsCount Problem

2 posts, 1 answers
  1. Meng
    Meng avatar
    57 posts
    Member since:
    Apr 2011

    Posted 24 Jun 2014 Link to this post

    Hi there,

    The value of property MaxFileInputsCount set to 4 is not limiting the user to select less then 4 files for RadAsyncUpload. Is there any way to limit user to select upto 4 files in one time to upload? Any suggestion is much appreciated.

    <telerik:RadAsyncUpload  ID="RadUpload1" ControlObjectsVisibility="None" MultipleFileSelection="Automatic" MaxFileInputsCount="4" TemporaryFileExpiration="01:00:00" runat="server"/>
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 Jun 2014 in reply to Meng Link to this post

    Hi Meng,

    With reference to this forum thread  setting MultipleFileSelection=Automatic and MaxFileInputsCount at the same time are not supported in the same scenario with RadAsyncUpload. As a work around please try to attach the OnClientFilesSelected event and get the count of the selected file, if it is greater than 4 cancel the event. And also attach the OnClientFilesUploaded event to get the count of uploaded file, check this with the selected file count and cancel the OnClientFilesSelected event if the count is greater is than 4. Please have a look into the sample code snippet.

    ASPX:
    <telerik:RadAsyncUpload ID="rasyncuploadAllFiles" MultipleFileSelection="Automatic" OnClientFilesSelected="selectingFiles" TemporaryFileExpiration="01:00:00" OnClientFilesUploaded="uploadedFileCount" runat="server" />

    JavaScript:
    var uploadedfileCount = 0;
    function selectingFiles(sender, args) {
        if (uploadedfileCount == 0) {
            if (args.get_count() > 4) {
                args.set_cancel(true);
            }
        }
        else if (args.get_count() > (4 - uploadedfileCount)) {
            args.set_cancel(true);
        }
    }
    function uploadedFileCount(sender, args) {
        uploadedfileCount = sender._uploadedFiles.length;
        alert(uploadedfileCount);
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top