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

[Solved] Save method don't pass selected files

2 Answers 103 Views
Upload
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tetha
Top achievements
Rank 1
Tetha asked on 29 Jul 2011, 11:14 AM
Hello,
I have a Upload control configured like this
@(Html.Telerik().Upload()
    .Name("UploadImages")
    .Multiple(false)
    .Async(async => async
            .Save("SalvaImmaginePrincipale","Immobile")
            .Remove("EliminaImmaginePrincipale","Immobile")
            .AutoUpload(true)
     )                   
  )
When try to upload files the Upload control don't pass the list of selected files to Save routine.
This is the code for save routine:
public ActionResult SalvaImmaginePrincipale(IEnumerable<HttpPostedFileBase> immagini)
{
    List<HttpPostedFileBase> imgList = immagini.ToList();
 
    if (imgList.Count == 1)
    {
        var file = imgList[0];
 
        string filename = Path.GetFileName(file.FileName);
        string path = Path.Combine(Server.MapPath("~/imgimmobili"), filename);
 
        file.SaveAs(path);
    }
 
    return Content("");
}

When the function is executed the parameter immagini is null.
Have an idea?
Thank in advance.

Mirko

2 Answers, 1 is accepted

Sort by
0
Accepted
T. Tsonev
Telerik team
answered on 01 Aug 2011, 08:44 AM
Hello Mirko,

The parameter name of the SalvaImmaginePrincipale method should be the same as the name of the upload:

public ActionResult SalvaImmaginePrincipale(IEnumerable<HttpPostedFileBase> UploadImages)

I hope this helps.

Kind regards,
Tsvetomir Tsonev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

0
Tetha
Top achievements
Rank 1
answered on 01 Aug 2011, 11:10 AM
Hello Tsvetomir,
thanks you.
Now it works!

Mirko
Tags
Upload
Asked by
Tetha
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Tetha
Top achievements
Rank 1
Share this question
or