blazor-devexpress-dot-blazor-dot-dxupload-c7eaa61a.md
Specifies a unique identifier used to associate the Upload component with uploaded files on the server.
Namespace : DevExpress.Blazor
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
[Parameter]
public string Name { get; set; }
| Type | Description |
|---|---|
| String |
A string value that specifies the identifier.
|
Specify the Name property to associate the Upload component with the server. This property is used to access uploaded files on the server. You should also set the UploadUrl property to the path of a server-side controller’s action that processes upload requests.
<DxUpload Name="myFile"
UploadUrl="https://localhost:10000/api/Upload/Upload/">
</DxUpload>
On the server side, create a controller with an action that accepts the uploaded file, checks it, and saves it to the target location.
Do one of the following to access the uploaded file:
Create an action with a parameter whose name matches the Name property value.
Use the Name property value to get the uploaded file from form variables.
The following example implements the upload controller:
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();
}
}
See Also