IFileInputSelectedFile.Type Property
Returns the file’s MIME type.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.1.dll
NuGet Package: DevExpress.Blazor
Declaration
string Type { get; }
Property Value
Type | Description |
---|---|
String | The file’s MIME type. |
Remarks
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