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

[Solved] My upload can't find the save controller MVC 3 Razor

1 Answer 64 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.
Dan
Top achievements
Rank 1
Dan asked on 14 Jul 2011, 12:38 PM
My console outputs that it cant find my save class in my LocalBusiness controller. Here's the code:

In my View


           @(Html.Telerik().Upload()
        .Name("attachments")
        .Async(async => async
         .Save("Save", "LocalBusinessController")
         .Remove("Remove", "LocalBusinessController")
        ))


In my Controller:

  public ActionResult Save(IEnumerable<HttpPostedFileBase> attachments)
        {
            // The Name of the Upload component is "attachments"
            foreach (var file in attachments)
            {
                // Some browsers send file names with full path. We only care about the file name.
                var fileName = Path.GetFileName(file.FileName);
                var destinationPath = Path.Combine(Server.MapPath("~/Comtent/images"), fileName);

                file.SaveAs(destinationPath);
            }

            // Return an empty string to signify success
            return Content("");
        }




        //removing and image
        public ActionResult Remove(string[] fileNames)
        {
            foreach (var fullName in fileNames)
            {
                var fileName = Path.GetFileName(fullName);
                var physicalPath = Path.Combine(Server.MapPath("../../Content/images"), fileName);

                // TODO: Verify user permissions

                if (System.IO.File.Exists(physicalPath))
                {
                    System.IO.File.Delete(physicalPath);
                }
            }

            // Return an empty string to signify success
            return Content("");
        }


In my _Layout.cshtml



    @(Html.Telerik().ScriptRegistrar())

Thankss in advance for any help!!

1 Answer, 1 is accepted

Sort by
0
Dan
Top achievements
Rank 1
answered on 14 Jul 2011, 02:01 PM
Never mind it works now. You have to remove 'Controller' at the end of;

.Save("Save", "LocalBusinessController")

So it will read

.Save("Save", "LocalBusiness")


In the documentation the Controller part is left in. Maybe it's just my app though.

By the way, this is the first tiome I#ve used Telerik. It's ridiculously good! When I'm an uber rich super developer (yeah, right!) I'll be buying!

Thanks,

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