Skip to main content

DxUpload.UploadFile(UploadFileInfo) Method

Uploads the specified file to the server.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

Declaration

public void UploadFile(
    UploadFileInfo fileInfo
)

Parameters

Name Type Description
fileInfo UploadFileInfo

The file to be uploaded.

Remarks

Use the UploadFile method to upload a specific file displayed in the Upload component except for files whose upload process was cancelled.

The uploaded file can be one of the items added in OnButtonClick mode or a file whose upload process was paused.

The following code snippet enables the OnButtonClick upload mode and displays a button that uploads the first file from the list on click.

<DxUpload UploadMode=UploadMode.OnButtonClick
          SelectedFilesChanged="@SelectedFilesChanged"
          AllowMultiFileUpload="true" 
          @ref="MyUpload" >
</DxUpload>

<DxButton Text="Upload the First File" Click=OnButtonClick />

@code {
    bool UploadVisible { get; set; } = false;
    IEnumerable<UploadFileInfo> Files { get; set; }
    UploadFileInfo FirstFile { get; set; }
    DxUpload MyUpload { get; set; }

    protected void SelectedFilesChanged(IEnumerable<UploadFileInfo> files) {
        Files = files;
        UploadVisible = files.ToList().Count > 0;

        InvokeAsync(StateHasChanged);
    }

    void OnButtonClick(){
         FirstFile = Files.First();
         MyUpload.UploadFile(FirstFile);
    }
}

Upload - Upload a File

To upload the specified files or all files, use the UploadFiles or UploadAllFiles method, respectively.

See Also