【发布时间】:2020-07-08 22:55:47
【问题描述】:
您好,我在使用blazor 和aspnet core 时遇到问题,我已经有一个uploads files 的组件,并且在上传它时会显示一个包含我上传的文件数据的表格,但我希望当上传文件时它只显示名称和progress bar,但我不知道如何执行此操作。
这是我上传文件的代码:
<h3 class="text-center">Subir Archivo</h3>
<div class="input-group col-md-4">
<div class="input-group-prepend">
<span class="input-group-text"></span>
</div>
<div class="custom-file">
<InputFile class="custom-file-input" id="inputGroupFile01" lang="es" multiple OnChange="HandleSelection" />
<label class="custom-file-label" for="inputGroupFile01">Seleccionar Archivo...</label>
</div>
</div>
<br />
@if (selectedFiles != null)
{
<table class="table table-hover text-center">
<thead>
<tr>
<th>Nombre</th>
<th>Tamaño en bytes</th>
<th>Fecha de Modificación</th>
<th>Tipo de Archivo</th>
</tr>
</thead>
<tbody>
@foreach (var file in selectedFiles)
{
<tr>
<td>@file.Name</td>
<td>@file.Size</td>
<td>@file.LastModified</td>
<td>@file.Type</td>
</tr>
}
</tbody>
</table>
}
@code {
IFileListEntry[] selectedFiles;
async Task HandleSelection(IFileListEntry[] files)
{
selectedFiles = files;
foreach (var selectedFiles in files)
{
if (files != null)
{
var ms = new MemoryStream();
await selectedFiles.Data.CopyToAsync(ms);
var content = new MultipartFormDataContent {
{ new ByteArrayContent(ms.GetBuffer()), "\"Upload\"", selectedFiles.Name } };
await Http.PostAsync("Upload", content);
}
}
}
}
我想要这样的东西,但我不知道这样做有多容易
【问题讨论】:
标签: c# css twitter-bootstrap asp.net-core blazor