I’m using jquery file uploader (per blueimp) and I’m wondering how I can direct the postback to a specificed http post back other than index.cshtml (post is going to index.cshtml for by default)?
For instance when calling Home/Bulk…then after selecting files the postback is defaulting to [httppost]index.cshtml()…How can I direct it to [httppost]bulk.cshtml()? Thx!
View (Bulk.cshtml):
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="@Url.Content("~/Scripts/jquery.ui.widget.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.iframe-transport.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.fileupload.js")" type="text/javascript"></script>
@using (Html.BeginForm("Bulk", "Home")) // I want this to direct back to httppost:bulk handler
{
<input id="fileupload" type="file" name="files" multiple="multiple"/>
}
Controller:
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(IEnumerable<HttpPostedFileBase> files)
{
foreach (var file in files)
{
var filename = Path.Combine(Server.MapPath("~/App_Data"), file.FileName);
file.SaveAs(filename);
}
return View();
}
public ActionResult Bulk()
{
return View();
}
[HttpPost]
public ActionResult Bulk(IEnumerable<HttpPostedFileBase> files)
{
foreach (var file in files)
{
var filename = Path.Combine(Server.MapPath("~/App_Data"), file.FileName);
file.SaveAs(filename);
}
return View();
}
}
You could use the
urlproperty when setting up the plugin to indicate to which action you want it to submit: