File upload with additional parameter

Earlier today I did a post regarding File Upload and being able to rename the incoming file.
I did find your example of Upload with a custom parameter.
The example showed the markup, but did not show what the Uploadcontroller looks like when you are passing a parameter.
I tried 2 different prototypes and both fail on execution.

// Single file upload
[HttpPost("upload/single")]
public async Task SingleAsync(IFormFile file)
{
// Single file upload
[HttpPost("upload/single")]
public async Task SingleAsync(IFormFile file,string NewFileName)
{

Can you provide an example of the UploadController for uploading a single file with a 'parameter' ?

Thank you in advance

Hey @mwechter,

You have full access to the source code of both components and examples including the upload controller:
radzen-blazor/UploadController.cs at master · radzenhq/radzen-blazor · GitHub

Link results to 404, are things moved elsewhere ?

1 Like

Hi @enchev ,

I'm using the Radzen IDE (Blazor Server) and can't get the upload controller to accept a parameter .
Without the parameter it works, when I change the controller to accept a parameter the file is empty .
What should be put in the URL and ParameterName when the controller route is to "upload/single/{id}"

Parameter datatype is int, are string parameters also allowed ?

Thanx!
Regards,

If using our sample upload controller the url should be set to upload/single and parameter name to file.

Ok , I want to pass the ID as a parameter ?? Not file .

I misunderstood your question. Do you need to upload single file or multiple files with additional parameter? If using our sample upload controller you don't have to specify ParameterName since both single and multiple files upload roots will use the default names - file and files.

I Want to upload a single file and include an additional parameter:

in the sample for the components the url looks like Url=@($"upload/single/{id}")

How to to do this in the IDE and pass the value of the parameter to the controller.


1 Like

So, the syntax for Url is :

${$"upload/single/{id}"}

In Load I set the value of id ( type int ).

Uploading a file the parameters in the controller has the value 0 . My value is not passed to the controller.
Also when you have defined an alternative text to "ChooseText" the designer does not adapts to this and displays the text "Choose" on the upload button.

File is uploaded but the parameter is not .. somehow this does not work for me?

@enchev ,

I had made and typo : This works now with the given syntax for url and leaving the ParameterName blank.

Thank you!