blazor-devexpress-dot-blazor-dot-dxupload-cbc24b12.md
Specifies the maximum file size in bytes.
Namespace : DevExpress.Blazor
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
[Parameter]
public int MaxFileSize { get; set; }
| Type | Description |
|---|---|
| Int32 |
An integer value that specifies the maximum file size in bytes.
|
Use the MaxFileSize and MinFileSize properties to limit an uploaded file’s size. The Upload component validates the file size on the client side and displays an error message if validation fails.
<DxUpload Name="myFile"
UploadUrl="https://localhost:10000/api/Upload/Upload/"
MaxFileSize="4000000"
MinFileSize="400">
</DxUpload>
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();
}
}
You can also use the following Upload properties to validate uploaded files on the client:
For additional information on the server-side validation, refer to Server-Side Validation.
See Also