Skip to main content
All docs
V24.1

DxFileInput.MaxFileSize Property

Specifies the maximum file size in bytes.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public int MaxFileSize { get; set; }

Property Value

Type Description
Int32

The maximum file size in bytes.

Remarks

Once a user adds a file to the file list, the File Input component validates the file size. If validation fails, the File Input cannot upload this file and displays an error message.

Specify MaxFileSize and MinFileSize properties to set maximum and minimum size limits of files that the File Input component can upload. The following example allows users to upload files from 1 to 4 KB in size:

<DxFileInput FilesUploading="OnFilesUploading" MinFileSize="1024" MaxFileSize="4096" />

@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