Blazor Upload file

I am successfully uploading files to the server using the Upload component but I have a few questions/issues.

  1. When I specify the value pdf/* in the Accept property, I am still seeing (and uploading) files of any type. Should this not filter for just pdf extensions?

  2. The file upload code is in the UploadController (and working)

// Single file upload
[HttpPost("upload/single")]
public async Task SingleAsync(IFormFile file)
{
try
{
// Put your code here
await UploadFile(file);
return StatusCode(200);
}
catch (Exception ex)
{
return StatusCode(500, ex.Message);
}
}

    public async Task UploadFile(IFormFile file)
    {
        if (file != null && file.Length > 0)
        {
            var imagePath = @"\Data\TempFiles";
            var uploadPath = _env.WebRootPath + imagePath;
            if (!Directory.Exists(uploadPath))
            {
                Directory.CreateDirectory(uploadPath);
            }          
            var fullPath = Path.Combine(uploadPath, file.FileName);
            fullUploadPath = fullPath;
            using (FileStream fileStream = new FileStream(fullPath, FileMode.Create, FileAccess.Write))
            {
                await file.CopyToAsync(fileStream);
            }              
        }
    }

I need to be able to specify a new name (without path) of the uploaded file different from the name on the client system.
Either by providing it to UploadFile or by renaming the file after UploadFile is complete in the 'Complete' event.
I haven't been able to find a way to pass another parameter to "SingleAsync" or to access IWebHostEnvironment from the Upload.Complete event.

Any assistance would be greatly appreciated.

The accept attrubute requires a valid file specifier. It seems for PDF files you need ".pdf".

Upload parameters are specified via the Url property as in our online demo

 <RadzenUpload Url=@($"upload/{customParameter}") />

In the example customParameter is a page property of type int. It is accessed in the controller like this:

public IActionResult Post(IFormFile file, int customParameter)
{
}

Thank you. I was able to resolve all of the current issues with your assistance.