how to upload the fie from user to server in asp.net mvc2

Posted by Richa Media and services on Stack Overflow See other posts from Stack Overflow or by Richa Media and services
Published on 2010-05-09T13:39:00Z Indexed on 2010/05/09 14:08 UTC
Read the original article Hit count: 356

Filed under:
|

in my apps (dev in MVC2) user can upload his images to server. how i can set url routing who handle the image and upload it to a specific location

currently i used it like a parameter ex;-

 routes.MapRoute("abcd2", "abcd/{id}/{param1}/{param2}/",
                new { controller = "abcd", action = "Index", id = 0, qxt = "" },
                new { action = new IsIndexConstraint() }, new string[] { "myapps.Controllers" });

by this code param2 is work i used param1 for sending file to server but he not worked

public ActionResult Index(HttpPostedFileBase param1 , string param2)
        {
            string str = "null";
            if (param1 != null)
            {
                param1.SaveAs(@"C:\img\" + param1.FileName);
                str = "func is work";
                //picture.SaveAs("C:\wherever\" + picture.FileName);
                return Content(str);
            }
            else
            {
                str = "func is not worked";
            }
            return Content(str);

} are anyone really want to help me.

param2 is work but param1 is not handle by web apps. are you suggest me how to do it.

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about c#