Skip to main content
All docs
V24.1

DxFileInput.AllowedFileExtensions Property

Specifies file extensions that the File Input component can upload.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public List<string> AllowedFileExtensions { get; set; }

Property Value

Type Description
List<String>

A list of allowed file extensions.

Remarks

Once a user selects files in the Open dialog or drags files onto a drop zone, the File Input component adds these files to the file list. In Instant upload mode (default), the component starts to upload a file once it appears in the file list. In OnClick upload mode, the File Input starts to upload a file once a user clicks an upload button.

Specify the following properties to limit the list of file types that the File Input component can upload:

AcceptedFileTypes

Specifies MIME types of files that users can add to the file list. The component passes this property value to the accept attribute of the underlying input HTML element. The element applies the corresponding filter to the Open dialog.

Accepted File Types

AllowedFileExtensions

Specifies extensions of files that the File Input component allows users to upload. Once a user adds a file to the file list, the component validates the file name extension. If validation fails, the File Input cannot upload this file and displays an error message.

File Extension Validation

The following example allows users to upload PNG, JPG, and PDF files:

<DxFileInput FilesUploading="OnFilesUploading" 
             AllowedFileExtensions="@(new List<string> { ".png", ".jpg", ".pdf" })" />

@code {
    async Task OnFilesUploading(FilesUploadingEventArgs args) {
        foreach (var file in args.Files) {
            /* The following code is intended for demonstration purposes only.
            Do not read a stream directly in memory to avoid performance and security-related issues. */
            using var stream = new System.IO.MemoryStream();
            await file.OpenReadStream(file.Size).CopyToAsync(stream);
        }
    }
}
See Also