![](/img/trans.png)
[英]Using Windows Authentication in Blazor WebAssembly with .NET Core
[英]Using InputFile on Blazor client WebAssembly with .net 5
我正在做這個教程來創建一個機器學習應用程序( https://www.dotnetcurry.com/aspnet-core/1537/blazor-ml-dotnet )。 我想將我的應用程序從 Blazor 服務器轉換為 Blazor 客戶端。
但我對 .net 5 上的 InputFile 有疑問。
@page "/identify"
@using System.Collections.Generic
@using BlazorClient.Data
@using BlazorInputFile
<div class="container">
<h1>Identify image</h1>
<p>
This component allows sending an image to run the image recognition model.
Select an image to start the upload and recognition process.
</p>
<form>
<InputFile multiple OnChange="OnImageFileSelected" accept="image/*"/>
</form>
<div class="row my-4">
@foreach (var image in selectedImages)
{
<div class="col-4">
<p>@image.Name</p>
</div>
}
</div>
</div>
@code {
List<IFileListEntry> selectedImages = new List<IFileListEntry>();
void OnImageFileSelected(IFileListEntry[] files)
{
selectedImages.AddRange(files);
}
}
我用這個解決方案解決了我的問題:
IReadOnlyList<IBrowserFile> selectedImages;
void OnImageFileSelected(InputFileChangeEventArgs eventArgs)
{
const int MaxAllowedFiles = 5;
selectedImages = eventArgs.GetMultipleFiles(MaxAllowedFiles);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.