Blazor InputFile can only upload 10 files?

William A Wang 236 Reputation points
2022-08-31T08:04:54.373+00:00

If upload files more than 10 with InputFile tag, it will show error:
blazor.server.js:1

       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.

Blazor
Blazor
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
    2022-09-01T02:07:31.137+00:00

    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,
    Rena

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. William A Wang 236 Reputation points
    2022-09-01T15:12:30.263+00:00

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

    0 comments No comments