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

[Solved] Upload Remove Not Working

1 Answer 234 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.
Douglas
Top achievements
Rank 1
Douglas asked on 04 May 2012, 06:07 PM
In the first look example (http://demos.telerik.com/aspnet-mvc/razor/upload) for the UPLOAD control there's code that looks like this for the view:

<div>
        <label for="LightboxImage">Lightbox Image</label>
        @(Html.Telerik().Upload()
                          .Name("mainImage")
                          .Multiple(false)
                          .Async(async => async
                          .Save("Upload", "Flyers")
                          .Remove("Remove", "Flyers")
                          .AutoUpload(true)
                   ))
</div>

And this for the controller:
public ActionResult Upload(HttpPostedFileBase mainImage)
{
    var fileName = Path.GetFileName(mainImage.FileName);
    var physicalPath = Path.Combine(Server.MapPath("~/Flyers"), fileName);
    mainImage.SaveAs(physicalPath);
    return Content("");
}
 
public ActionResult Remove(string mainImage)
{
    var fileName = Path.GetFileName(mainImage);
    var physicalPath = Path.Combine(Server.MapPath("~/Flyers"), fileName);
 
    if(System.IO.File.Exists(physicalPath))
        System.IO.File.Delete(physicalPath);
    return Content("");
     
}

The Upload works.

The mainImage parameter for the Remove ActionResult is always NULL so it's not working.

Where is this parameter set?

Thanks

1 Answer, 1 is accepted

Sort by
Tags
Upload
Asked by
Douglas
Top achievements
Rank 1
Answers by
Douglas
Top achievements
Rank 1
Share this question
or