blazor-devexpress-dot-blazor-dot-ifileinputselectedfile-f72658c5.md
Returns the file’s MIME type.
Namespace : DevExpress.Blazor
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
string Type { get; }
| Type | Description |
|---|---|
| String |
The file’s MIME type.
|
The following example validates types of uploaded files:
<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