Back to Devexpress

DxFileInput.UploadAllFiles() Method

blazor-devexpress-dot-blazor-dot-dxfileinput-e3779975.md

latest3.7 KB
Original Source

DxFileInput.UploadAllFiles() Method

Uploads all files displayed in the file list.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
public void UploadAllFiles()

Remarks

Note

UploadAllFiles, UploadFile, and UploadFiles methods ignore files whose upload processes failed or were canceled.

Once a user selects files in the Open dialog or drags files onto a drop zone, the File Input component adds these files to the file list. The file list displays each file’s upload status and upload, cancel, reload, and remove buttons. On the image below, the file list contains 4 files in different states:

Handle the SelectedFilesChanged event to access the collection of files in the file list. Call the following methods to manage these files in code:

Start UploadCancel UploadRestart Canceled UploadRemove Files from List
One FileUploadFileCancelFileUploadReloadFileRemoveFile
Multiple FilesUploadFilesCancelFilesUploadReloadFilesRemoveFiles
All FilesUploadAllFilesCancelAllFilesUploadReloadAllFilesRemoveAllFiles

The following example displays a button that uploads all files displayed in the file list:

razor
<DxFileInput @ref="MyFileInput"
             AllowMultiFileUpload="true"
             UploadMode="UploadMode.OnButtonClick"
             FilesUploading="OnFilesUploading" />

<DxButton Text="Upload All Files" Click="OnUploadButtonClick" />

@code {
    DxFileInput MyFileInput { get; set; }

    void OnUploadButtonClick() {
        MyFileInput.UploadAllFiles();
    }
    async Task OnFilesUploading(FilesUploadingEventArgs args) {
        foreach (var file in args.Files) {
            /* The following code is intended for demonstration purposes only.
            Do not read a stream directly in memory to avoid performance and security-related issues. */
            using var stream = new System.IO.MemoryStream();
            await file.OpenReadStream(file.Size).CopyToAsync(stream);
        }
    }
}

See Also

DxFileInput Class

DxFileInput Members

DevExpress.Blazor Namespace