This is a migrated thread and some comments may be shown as answers.

RadAsyncUpload MaxFileInputsCount Problem

1 Answer 247 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Meng
Top achievements
Rank 1
Meng asked on 24 Jun 2014, 07:47 PM
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"/>

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 25 Jun 2014, 03:06 AM
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.
Tags
AsyncUpload
Asked by
Meng
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or