This is a migrated thread and some comments may be shown as answers.

How to handle including additional data to file upload

4 Answers 372 Views
Upload
This is a migrated thread and some comments may be shown as answers.
BitShift
Top achievements
Rank 1
Veteran
BitShift asked on 30 Apr 2020, 10:10 PM

Seeing this example, how can I pass along extra values in the data that is posted back to the server, along with the file(s)?  Custom model?

https://demos.telerik.com/aspnet-core/upload/index

4 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 05 May 2020, 11:41 AM

Hello Randal,

You can send additional data in the upload event through the e.data object. Please refer to this How-To article demonstrating how to achieve that.

Let me know if you have any questions.

Regards,
Martin
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
BitShift
Top achievements
Rank 1
Veteran
answered on 11 May 2020, 04:12 PM

Trying to use this example but with Razorpages

https://demos.telerik.com/aspnet-core/upload/asyncupload

When calling the save method, what does one use for the controller name if using Razorpages?

0
BitShift
Top achievements
Rank 1
Veteran
answered on 11 May 2020, 05:17 PM

I think I managed to figure out a solution, but I would benefit by having some notes somewhere on each control, or even a seperate area specific to Razorpages, as others have requested.  

In my case, I replaced the call to Save with SaveURL, eg. 
The mvc example...

        @(Html.Kendo().Upload()
            .Name("files")
            .Async(a => a
                .Save("Async_Save", "Upload")
                .Remove("Async_Remove", "Upload")
                .AutoUpload(true)
            )

becomes this for using in a Razorpage...

        @(Html.Kendo().Upload()
            .Name("files")
            .Async(a => a
                .SaveURL("/TestUpload?handler=AsyncSave")
                .AutoUpload(true)
            )

Where "TestUpload" is the name of the Razorpage.

Then, your handler needs to be
public async Task<ActionResult> OnPostAsyncSave(IEnumerable<IFormFile> files)

0
Martin
Telerik team
answered on 14 May 2020, 01:41 PM

Hello Randal,

I am glad that you were able to modify the example for Razor Pages thank you for sharing the way to do it. As for the documentation, we are making an effort in that direction to include Razor Pages articles and examples. 

Regards,
Martin
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Upload
Asked by
BitShift
Top achievements
Rank 1
Veteran
Answers by
Martin
Telerik team
BitShift
Top achievements
Rank 1
Veteran
Share this question
or