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

No Files Returned to Controller

3 Answers 253 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Arie
Top achievements
Rank 1
Arie asked on 26 Oct 2016, 12:05 PM

 

We are currently working with the Upload control in what would seem to be a very simple setup.

@(Html.Kendo().Upload()
                            .Name("files")
                            .ShowFileList(false)
                            .Multiple(false)
                            .Async(a => a
                                 .Save("Save", "Patient")
                                 .AutoUpload(true)
                                 .SaveField("files")
                              )
                            .Validation(validation => validation.AllowedExtensions(new string[] { ".gif", ".jpg", ".png" }))
                              )

 

 

and our controller is defined as such

[HttpPost]
public async Task<IActionResult> Save(IEnumberable<HttpPostedFileBase> files)

 

What is happening is that the files parameter is not null but has a count of 0. This is in an ASP.NET core MVC app.

What could the issue be? Is there something simple we are missing here?

Thanks
AJ

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Eduardo Serra
Telerik team
answered on 26 Oct 2016, 03:46 PM
Hello Arie,

This issue often occurs because the name of the widget doesn't match the name of the parameter received by the controller, but they match in your case so we're good on that front.

I noticed that instead of IEnumerable you're setting the type as IEnumberable, with an extra B; let's fix that and see if the problem keeps occurring.

Thank you.

Regards,
Eduardo Serra
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
0
Arie
Top achievements
Rank 1
answered on 26 Oct 2016, 03:51 PM

That's just a typo. Yes the problem is still present.

 

I have also tried List but it has the same problem.

0
Veselin Tsvetanov
Telerik team
answered on 28 Oct 2016, 11:14 AM
Hi Arie,

In order the Upload to work properly, the HttpPostedFileBase class should implement the Microsoft.AspNetCore.Http.IFormFileinterface.

Also, you may have to return an ActionResult, instead of the asynchronous Task<IActionResult>:
public ActionResult Save(IEnumberable<HttpPostedFileBase> files)

Regards,
Veselin Tsvetanov
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Tags
Upload
Asked by
Arie
Top achievements
Rank 1
Answers by
Eduardo Serra
Telerik team
Arie
Top achievements
Rank 1
Veselin Tsvetanov
Telerik team
Share this question
or