Back to Devexpress

DxUpload.UploadMode Property

blazor-devexpress-dot-blazor-dot-dxupload-2d5165cc.md

latest2.6 KB
Original Source

DxUpload.UploadMode Property

Specifies how the Upload component uploads files to the server.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[DefaultValue(UploadMode.Instant)]
[Parameter]
public UploadMode UploadMode { get; set; }

Property Value

TypeDefaultDescription
UploadModeInstant

A UploadMode enumeration value.

|

Available values:

NameDescription
Instant

Files are uploaded instantly when a user selects or drops them.

| | OnButtonClick |

Files are uploaded after a user clicks the common upload button or individual buttons for each file.

|

Remarks

Use the UploadMode property to specify how the Upload component uploads files to the server. The following upload modes are available:

  • Instant (Default) - Files are uploaded when a user selects or drops them.
  • OnButtonClick - Files are uploaded after a user clicks the common upload button or individual buttons for each file.

The following code snippet enables the UploadMode.OnButtonClick upload mode in the component.

razor
<DxUpload Name="myFile" 
          UploadUrl="@GetUploadUrl("api/Upload/Upload/")"
          UploadMode="UploadMode.OnButtonClick">
</DxUpload>
csharp
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BlazorDemo.AspNetCoreHost;
[Route("api/[controller]")]
[ApiController]
public class UploadController : ControllerBase {
    [HttpPost("[action]")]
    public ActionResult Upload(IFormFile myFile) {
        try {
            // Write code that saves the 'myFile' file.
            // Don't rely on or trust the FileName property without validation.
        } catch {
            return BadRequest();
        }
        return Ok();
    }
}

Run Demo: Upload - Upload Modes

See Also

DxUpload Class

DxUpload Members

DevExpress.Blazor Namespace