I have a simple file upload which uses the BlazorInputFile. I can add a file and it hits the onChange function I have specified however the name of the file never appears on the screen and when I go to submit the form, it says that it's empty.
The form:
<EditForm Model="@Item" OnValidSubmit="@SubmitForm">
<DataAnnotationsValidator />
<div class="modal-body">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>File</label>
<InputFile OnChange="LoadFile"/>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-success">Save changes</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal" @onclick="() => Close()">Close</button>
</div>
<ValidationSummary />
</EditForm>
@code {
public FormItem Item = new FormItem();
private IFileListEntry UploadedFile;
// So on change it gets in here and I can see that we have a item uploaded
private async Task LoadFile(IFileListEntry[] files)
{
if (files.Count() != 0)
{
UploadedFile = files.FirstOrDefault();
}
this.StateHasChanged();
}
protected async Task SubmitForm(EditContext editContext)
{
}
}
The Item
class has one attribute:
[Required]
public IFileListEntry File { get; set; }
I have seen that this may be an issue with the BlazorInputFile component itself but I was wondering if anyone else has come across this issue?
Currently running Blazor with ASP.Net Core 3.1