Restrict upload to 5 files at a time

4 posts, 0 answers
  1. Peter
    Peter avatar
    71 posts
    Member since:
    Mar 2012

    Posted 27 Mar 2014 Link to this post

    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
  2. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 01 Apr 2014 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Peter
    Peter avatar
    71 posts
    Member since:
    Mar 2012

    Posted 01 Apr 2014 in reply to Vessy Link to this post

    Thanks, this first File Explorer implementation is for a few internal users, so I am not concerned about them loosing "multi-file" selection.

  5. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 03 Apr 2014 Link to this post

    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.

     
Back to Top