Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 1.7 KB

File metadata and controls

54 lines (40 loc) · 1.7 KB

MInputFile

MInputFile uploads one or more files through the registered IFileUploadService. MInputFileSimple provides a compact single-file variant.

Setup

Register an application implementation:

services.AddScoped<IFileUploadService, FileUploadService>();

Both controls are Blazor input components and must receive @bind-Value or @bind-Values.

Simple

<MInputFileSimple @bind-Value="document" Accept=".pdf,image/*" />

@code {
    private IFile document;
}

Advanced

<MInputFile MaxAllowedFiles="5"
            @bind-Values="documents"
            Accept=".pdf,image/*"
            FileInputName="attachments"
            AdditionalHeaders="uploadHeaders"
            OnFileClicked="OpenFile" />

@code {
    private ICollection<IFile> documents = new List<IFile>();
    private IDictionary<string, string> uploadHeaders =
        new Dictionary<string, string> { ["Category"] = "Invoices" };
}

Parameters

Parameter Description
MaxAllowedFiles Maximum number of files; defaults to one.
Value / Values Single or multiple bound file values.
Accept Browser file-type filter.
FileInputName Logical input name sent to the upload service.
AdditionalHeaders Application metadata passed to the upload service.
Attributes Validation or display attributes associated with the field.
OnFileClicked Called when an uploaded file is selected.

View the runnable examples · View the upload service example