How do I get jQuery's Uploadify plugin to work with ASP.NET MVC?

前端 未结 6 1348
梦如初夏
梦如初夏 2020-12-04 09:37

I\'m in the process of trying to get the jQuery plugin, Uploadify, to work with ASP.NET MVC.

I\'ve got the plugin showing up fine with the following JavaScript snipp

6条回答
  •  没有蜡笔的小新
    2020-12-04 10:41

    The problem might be that you need to specify that the action you are uploading to is set to Post...it won't work with the action as a Get action.

    So, this:

    public string Upload(HttpPostedFileBase FileData)
    {
       //do something
    }
    

    Should be this:

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Upload(HttpPostedFileBase FileData)
    {
       //do something
    }
    

    Also, be aware that if you are using this in a "logged in" section of your site, you should take a look here for a known bug with uploadify and authentication: http://geekswithblogs.net/apopovsky/archive/2009/05/06/working-around-flash-cookie-bug-in-asp.net-mvc.aspx

    Also, just an aside, there are several ways in MVC to handle file uploads (using Request.Files as per Rory Fitzpatrick's suggestion, as well as passing the HttpPostedFileBase file as an argument in the action definition). It shouldn't really matter in order to get Uploadify to work.

提交回复
热议问题