DxUpload.ShowFileList Property
Specifies whether to show the file list.
Namespace: DevExpress.Blazor
Assembly:
DevExpress.Blazor.v21.1.dll
NuGet Package:
DevExpress.Blazor
Declaration
[Parameter]
public bool ShowFileList { get; set; }
Property Value
Type |
Description |
Boolean |
true, to show the file list; otherwise, false.
|
Once a user selected a file, the Upload packs the file into an Ajax request and sends this request to the server. The Upload displays this file in the list and indicates the upload status.
Set the ShowFileList property to false to hide the file list.
<DxUpload Name="myFile" UploadUrl="https://localhost:10000/api/Upload/UploadFile/"
ShowFileList="false">
</DxUpload>
using System.IO;
using System.Linq;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
[Route("api/[controller]")]
public class UploadController : ControllerBase {
private readonly IWebHostEnvironment _hostingEnvironment;
public UploadController(IWebHostEnvironment hostingEnvironment) {
_hostingEnvironment = hostingEnvironment;
}
[HttpPost]
[Route("UploadFile")]
// "myFile" is the value of the Upload's "Name" property.
public ActionResult UploadFile(IFormFile myFile) {
try {
// Specify the target location for the uploaded files.
var path = Path.Combine(_hostingEnvironment.WebRootPath, "uploads");
// Check whether the target directory exists; otherwise, create it.
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
using (var fileStream = System.IO.File.Create(Path.Combine(path, myFile.FileName))) {
// Check the file here (its extension, safity, and so on).
// If all checks are passed, save the file.
myFile.CopyTo(fileStream);
}
} catch {
Response.StatusCode = 400;
}
return new EmptyResult();
}
}
See Also