Blazor InputFile can only upload 10 files?

William A Wang 236 Reputation points

If upload files more than 10 with InputFile tag, it will show error:

       Uncaught (in promise) Error: System.InvalidOperationException: The maximum number of files accepted is 10, but 76 were supplied.  
   at Microsoft.AspNetCore.Components.Forms.InputFileChangeEventArgs.GetMultipleFiles(Int32 maximumFileCount)  
   at Pic.Pages.Picadd.LoadFiles(InputFileChangeEventArgs e) in .\Pic\Pages\Picadd.razor:line 0  
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)  
    at kt.endInvokeDotNetFromJS (blazor.server.js:1:3700)  
    at blazor.server.js:1:72054  
    at Array.forEach (<anonymous>)  
    at kt._invokeClientMethod (blazor.server.js:1:72040)  
    at kt._processIncomingData (blazor.server.js:1:70082)  
    at connection.onreceive (blazor.server.js:1:64485)  
    at yt._poll (blazor.server.js:1:44148)  

Is there any way to increase the limitation.

A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,381 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rena Ni - MSFT 2,061 Reputation points

    Hi @William A Wang ,

    From the official document about how to upload multiple files in blazor server you can see it defines maxAllowedFiles value which can limit the file size by method GetMultipleFiles(maxAllowedFiles). If you do not set any value in GetMultipleFiles(), it will by default allow 10 files.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards,

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. William A Wang 236 Reputation points

    Ah, I see, the GetMultipleFiles function accept a argument instead of the default value, and my code didn't pass the value.

    0 comments No comments