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

Restrict upload to 5 files at a time

3 Answers 99 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 27 Mar 2014, 03:11 PM
I would like to restrict the number of a files that can be uploaded at a time to 5.

I reviewed this posting and applied this code:
http://www.telerik.com/forums/limit-number-of-files-to-be-uploaded

rfeExplorer.Upload.MaxFileInputsCount = 5

But the upload modal allows an unlimited number of files to be selected.

Peter

3 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 01 Apr 2014, 01:24 PM
Hi Peter,

Restricting the file count of the uploaded files is connected with the upload control, which is currently used in FileExplorer. The provided by you code is applicable only when FileExplorer is used with RadUpload (EnableAsyncUpload = "False").

In case you are working with RadAsyncUpload, though, you have two possible options to restrict the file inputs.
  • Configure the RadAsyncUpload's MaxFileInputsCount and MultipleFileSelection properties in the following way (a limitation described here):
    protected void Page_Load(object sender, EventArgs e)
    {
        rfeExplorer.AsyncUpload.MaxFileInputsCount = 3;
        rfeExplorer.AsyncUpload.MultipleFileSelection = Telerik.Web.UI.AsyncUpload.MultipleFileSelection.Disabled;
    }
  • Attach a handler to the asyncUpload's ClientFileSelected event and cancel it in case they exceed the desired count. You will also need to configure the MaxFileInputsCount here:
    protected void Page_Load(object sender, EventArgs e)
    {
        rfeExplorer.AsyncUpload.MaxFileInputsCount = 5;
        rfeExplorer.AsyncUpload.OnClientFilesSelected = "filesSelected";
    }
    <script>
        function filesSelected(asyncUpload, args) {
            if (args.get_count() > 5){
                alert("Please, select less than 5 files.");
                args.set_cancel(true);}
        }
    </script>
The main advantage of choosing the second approach is that the users will be allowed to select all 5 files at a time, not one by one. Hope this helps.

Regards,
Vessy
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
Peter
Top achievements
Rank 1
answered on 01 Apr 2014, 02:24 PM
Thanks, this first File Explorer implementation is for a few internal users, so I am not concerned about them loosing "multi-file" selection.

0
Vessy
Telerik team
answered on 03 Apr 2014, 12:20 PM
Hi Peter,

In such case I am glad that both of the proposed solutions are applicable for your scenario. Should any further questions appear - do not hesitate to contact us again.

Kind regards,
Vessy
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
FileExplorer
Asked by
Peter
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Peter
Top achievements
Rank 1
Share this question
or