how to upload the fie from user to server in asp.net mvc2
- by Richa Media and services
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.