blazor-devexpress-dot-blazor-dot-dxupload-374086e2.md
Specifies the CSS selector of a container or HTML element wherein users can drop files to upload.
Namespace : DevExpress.Blazor
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
[Parameter]
public string ExternalDropZoneCssSelector { get; set; }
| Type | Description |
|---|---|
| String |
The CSS selector of a container or HTML element where users can drop files.
|
Use the ExternalDropZoneCssSelector property to enable drag and drop functionality in the Upload. This property specifies the CSS selector of an external zone where users can drop files to upload.
You can also use the ExternalDropZoneDragOverCssClass to define the CSS class that is applied to the drop zone when users drag files over it.
<div id="overviewDemoDropZone" class="card custom-drop-zone bg-light rounded-3 w-100 m-0">
<span class="drop-file-icon mb-3"></span>
<span>Drag and Drop File Here</span><span class="m-1">
</div>
<DxUpload Name="myFile"
UploadUrl="https://localhost:10000/api/Upload/Upload/"
ExternalDropZoneCssSelector="#overviewDemoDropZone"
ExternalDropZoneDragOverCssClass="bg-light border-secondary text-dark" >
</DxUpload>
.custom-drop-zone {
padding: 0 !important;
border-style: dashed !important;
border-width: 2px !important;
height: 230px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.custom-drop-zone svg {
width: 42px;
height: 42px;
}
.drop-file-icon {
background-size: contain;
mask-repeat: no-repeat;
-webkit-mask-repeat: no-repeat;
background-position: center center;
background-color: currentColor;
width: 48px;
height: 48px;
-webkit-mask-image: url("../images/icons/drop-file.svg");
mask-image: url("../images/icons/drop-file.svg");
}
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