FileInput max size (Window forms)

Hi there,
I am using RadzenFileInput to handle my .zip file.

When I pick a 26MB file, it throw an UploadErrorEventArgs error "Unable to read file as base64 string. File too large.";

Can you give me the limit of file length?
Thanks

FileInput can be used for small files only, for bigger files you can use Upload component.

1 Like

Thank for your help.
I am working with desktop application so I need to handle the file in local machine.
To handle the big file, I created a new component the below:

<RadzenCard>
    <RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">@_title</RadzenText>
    <div class="rz-fileupload valid rz-state-empty w-100">
        <div class="rz-fileupload-buttonbar">
            <label class="rz-fileupload-choose rz-button rz-secondary" style="margin: 0;">
                @_chooseText
                <InputFile OnChange="@LoadFiles" multiple accept="@_accept"/>
            </label>
        </div>

        <div class="rz-fileupload-content rz-corner-bottom">
            @if(_selectedFiles != null)
            {
                foreach (var file in _selectedFiles)
                {
                    <div class="rz-fileupload-files">
                        <div class="rz-fileupload-row">
                            <div></div>
                            <div>@file.FileName</div>
                            <div>@file.FileLength</div>
                            <div>
                                <button type="button" class="rz-button rz-button-icon-only rz-light" @onclick="() => Remove(file)">
                                    <span class="rz-button-icon-left rz-icon-trash" style="display: block;"></span>
                                </button>
                            </div>
                        </div>
                    </div>
                }
            }
        </div>
    </div>
</RadzenCard>
@code {
    #region parameters
    [Parameter]
    public string _title { get; set; }
    [Parameter]
    public string _chooseText { get; set; }
    [Parameter]
    public string _accept { get; set; }

    // ref parameters
    [Parameter]
    public EventCallback<List<FileInputModel>> _selectedFilesChanged { get; set; }
    [Parameter]
    public List<FileInputModel> _selectedFiles { get; set; }
    #endregion

    int _fileSizeLimit = 25 * 1000 * 1000; // about 25MB

    async System.Threading.Tasks.Task Remove(FileInputModel file)
    {
        _selectedFiles.Remove(file);
        StateHasChanged();
    }

    private async Task LoadFiles(InputFileChangeEventArgs e)
    {
        if (_selectedFiles == null) _selectedFiles = new List<FileInputModel>();

        await JSRuntime.InvokeVoidAsync("Utils.blockPage");
        try
        {
            foreach (var file in e.GetMultipleFiles(10))
            {
                using (var ms = new MemoryStream())
                {
                    var val = new byte[file.Size];
                    var fileLength =  await file.OpenReadStream(_fileSizeLimit).ReadAsync(val);

                    _selectedFiles.Add(new FileInputModel
                    {
                        FileValue = val,
                        FileName = file.Name,
                        FileLength = fileLength
                    });
                }
            }

            // thông báo sự kiện thay đổi giá trị cho tham số
            await _selectedFilesChanged.InvokeAsync(_selectedFiles);

            await JSRuntime.InvokeVoidAsync("Utils.unlockPage");
        }
        catch (Exception ex)
        {
            await JSRuntime.InvokeVoidAsync("Utils.unlockPage");
            MessageBox.Show(ex.Message);
        }
    }
}