Back to Devexpress

IFileInputSelectedFile.Type Property

blazor-devexpress-dot-blazor-dot-ifileinputselectedfile-f72658c5.md

latest1.6 KB
Original Source

IFileInputSelectedFile.Type Property

Returns the file’s MIME type.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
string Type { get; }

Property Value

TypeDescription
String

The file’s MIME type.

|

Remarks

The following example validates types of uploaded files:

razor
<DxFileInput AcceptedFileTypes="fileTypes" FilesUploading="OnFilesUploading" />

@code {
    List<string> fileTypes = new List<string> { "image/jpg", "image/jpeg", "image/png"};

    async Task OnFilesUploading(FilesUploadingEventArgs args) {
        foreach (var file in args.Files) {
            if (fileTypes.Contains(file.Type)) {
                /* 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

IFileInputSelectedFile Interface

IFileInputSelectedFile Members

DevExpress.Blazor Namespace