Limit number of Files to be uploaded

7 posts, 1 answers
  1. chris
    chris avatar
    32 posts
    Member since:
    Jul 2011

    Posted 03 Jan 2012 Link to this post

    Hello everyone,

    I see that there is a way to limit the number of file inputs with the RadAsyncUpload control but what I am trying to do is limit the user to only be able to upload 5 files. Is there a settle that will limit the user to only upload a set number of files?

  2. Answer
    Dimitar Terziev
    Dimitar Terziev avatar
    1268 posts

    Posted 03 Jan 2012 Link to this post

    Hi Chris,

    You could limit the number of the uploaded files using the MaxFileInputsCount property of the RadAsyncUpload. In your case you should set it to 5.

    All the best,
    Dimitar Terziev
    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
    CHOON AIK avatar
    7 posts
    Member since:
    Sep 2012

    Posted 22 Jun 2015 in reply to Dimitar Terziev Link to this post

    Drag  and Drop is giving javascript error when "MaxFileInputsCount" property is set.

     Below is my design,

    <telerik:RadAsyncUpload runat="server" ID="rauUpload" 
                        ChunkSize="1048576" InputSize="60" DropZones="#DropZone1" 
                        MaxFileInputsCount="5" MaxFileSize="2000000000" PostbackTriggers="btnUpload" />

  4. Nencho
    Nencho avatar
    1829 posts

    Posted 24 Jun 2015 Link to this post

    Hello Choon,

    I am afraid that I was unable to replicate the mentioned javscript error, using the provided code-snippet. Could you please specify what exactly is the error and what is the version of our controls that you are currently using?

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. Darryl
    Darryl avatar
    2 posts
    Member since:
    Nov 2012

    Posted 24 Oct 2017 Link to this post

    I am not able to replicate that, but my QA found a different issue.

    While upload file count is limited to 5, when using the select button, I am still able to drag unlimited files to upload.

    Is there a way to fix this drag/drop limit issue?

  6. Darryl
    Darryl avatar
    2 posts
    Member since:
    Nov 2012

    Posted 24 Oct 2017 in reply to Darryl Link to this post

    Here was my solution:

    I added the corresponding parameters, to the upload control:




    <telerik:RadCodeBlock ID="rad_block" runat="server">
        <script type="text/javascript">
            function Rad_OnClientFileUploaded(sender, e) {
                if (sender._uploadedFiles.length > sender._maxFileCount) {
                    alert('File discarded! Exceeds max file limit of ' + sender._maxFileCount);
            function Rad_OnClientFileRemoved(sender, e) {
  7. Peter Milchev
    Peter Milchev avatar
    658 posts

    Posted 27 Oct 2017 Link to this post

    Hello Darryl,

    I would suggest you try the OnClientFilesSelected event which would prevent the unnecessary upload of files.

    Please find attached a sample project implementing the suggested approach. To run the project, the Telerik assemblies for .NET 4.5 should be added to the Bin folder.

    function OnClientFilesSelected(sender, args) {
        var selector = sender.get_renderMode() == 2 ? '.ruInputs .ruFileLI' : '.ruInputs .ruUploadProgress'; // render mode 2 is Lightweight
        if (args.get_count() + $telerik.$(selector, sender.get_element()).length > sender.get_maxFileCount()) {
            // alert user that the maxFile limit is exceed

    The additional checks are for the case where a upload is ongoing.

    Peter Milchev
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top