i created a button on radzen page to download a file inside wwwroot folder.
the file path and file name is saved inside my table in SQL server database.
this is the code
Download Files
and this is the function of DownloadFileFromURL
and this is the code @code {
private async Task DownloadFileFromURL()
{
var fileName = $"{tblTicket.AttchedFileName}";
var fileURL = $"{environment.WebRootPath}";
await JS.InvokeVoidAsync("triggerFileDownload", fileName, fileURL);
}
and for you information i Injected this
@inject IJSRuntime JS @inject IWebHostEnvironment environment
.
so it doesn't work . can you help me
This error is not related to the Radzen.Blazor components. The web browser is restricted and cannot have access to the server file system. You should use an action that reads the file from the database and returns it as a file stream. Here is a related question: c# - Stream File Content from DB - Stack Overflow
the problem is the whole file ( even it's a PDFf or image ) is inside the wwwroot folder but i just save the file path to the database.
so how could i make file stream from the database which just have the file path not storing the file data.
so i made my code like this private async Task DownloadFileFromURL()
{
var fileName = $"{tblTicket.AttchedFileName}";
var fileURL = $"{environment.WebRootPath}";
NavigationManager.NavigateTo($"/{fileURL}", true);
await JS.InvokeVoidAsync("triggerFileDownload", fileName, fileURL);
}
but when i press the button it give's me this error.