Sample project plugin jquery File Upload plugin implemented in ASP .NET MVC3

家住魔仙堡 提交于 2019-12-03 03:27:51

问题


I need to implement in my project ASP .NET MVC3 the jQuery file upload plugin:

http://blueimp.github.com/jQuery-File-Upload/

I have been Googling and I haven't found a whole project, only pieces of code. I don't know how to implement it.

Can someone help me? Can someone tell me where I can download a sample project or code?


回答1:


I've created a sample ASP.NET MVC 3 project on GitHub that shows how to use a full plug-in functionality, including deletion and download.




回答2:


Did you read the documentation of the plugin that you are trying to use? Did you try the basic plugin functionality? Did you try to create a new ASP.NET MVC 3 application in Visual Studio using the default template?

Did you try writing a simple 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 Json(files.Select(x => new { name = x.FileName }));
    }
}

and a corresponding view:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="@Url.Content("~/Scripts/blueimp/js/vendor/jquery.ui.widget.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/blueimp/js/jquery.iframe-transport.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/blueimp/js/jquery.fileupload.js")" type="text/javascript"></script>

<script type="text/javascript">
    $(function () {
        $('#fileupload').fileupload({
            dataType: 'json',
            url: '@Url.Action("index")',
            done: function (e, data) {
                $.each(data.result, function (index, file) {
                    $('<p/>').text(file.name).appendTo(document.body);
                });
            } 
        });
    });
</script>

<input id="fileupload" type="file" name="files" multiple="multiple"/>

If you haven't, I invite you to do so.



来源:https://stackoverflow.com/questions/9361789/sample-project-plugin-jquery-file-upload-plugin-implemented-in-asp-net-mvc3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!