radzenhq / radzen-blazor

Radzen Blazor is a set of 90+ free native Blazor UI components packed with DataGrid, Scheduler, Charts and robust theming including Material design and FluentUI.
https://www.radzen.com
MIT License
3.47k stars 777 forks source link

RadzenUpload Component doesn't send request with file #1508

Closed walik92 closed 4 months ago

walik92 commented 4 months ago

Describe the bug Since 4.28.4 RadzenUpload component doesn't send request with file to server. There isn't any error in console of browser.

To Reproduce To reproduce BUG use below code:

<RadzenRow>
    <RadzenColumn Size="12">
        <RadzenUpload @ref="_upload" Accept=".png, .jpg, .jpeg, .tif, .tiff, .bmp, .pdf, .doc, .docx" ChooseText="Choose" Auto="false" Multiple="true" class="w-100">
        </RadzenUpload>
    </RadzenColumn>
</RadzenRow>
<RadzenRow class="mt-3">
    <RadzenColumn Size="12">
        <RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.End" Gap="10px">
            <RadzenButton Text="Add" Click="Submit" ButtonStyle="ButtonStyle.Primary"/>
        </RadzenStack>
    </RadzenColumn>
</RadzenRow>

@code {

    [Parameter]
    public Guid EnrollmentId { get; set; }

    RadzenUpload _upload = null!;

    async Task Submit()
    {
        _upload.Url = $"/api/enrollments/{EnrollmentId}/attachments";
        if (_upload.HasValue)
        {
            // this method doesn't send request and nothing happen
            await _upload.Upload();
        }
    }
}

Expected behavior Executing 'Upload' method of '_upload' object will send request with file.

Desktop

enchev commented 4 months ago

Just setting the Url like this will not work - you need to attach it to variable at least:


<RadzenRow>
    <RadzenColumn Size="12">
        <RadzenUpload @ref="_upload" Url="@url" Accept=".png, .jpg, .jpeg, .tif, .tiff, .bmp, .pdf, .doc, .docx" ChooseText="Choose" Auto="false" Multiple="true" class="w-100">
        </RadzenUpload>
    </RadzenColumn>
</RadzenRow>
<RadzenRow class="mt-3">
    <RadzenColumn Size="12">
        <RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.End" Gap="10px">
            <RadzenButton Text="Add" Click="Submit" ButtonStyle="ButtonStyle.Primary" />
        </RadzenStack>
    </RadzenColumn>
</RadzenRow>

@code {

    [Parameter]
    public Guid EnrollmentId { get; set; }

    RadzenUpload _upload = null!;
    string url;

    async Task Submit()
    {
        url = $"upload/single";
        if (_upload.HasValue)
        {
            // this method doesn't send request and nothing happen
            await _upload.Upload();
        }
    }
}